123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- namespace UnityEditor.U2D.Animation
- {
- internal interface ISkinningCachePersistentState
- {
- String lastSpriteId
- {
- get;
- set;
- }
- Tools lastUsedTool
- {
- get;
- set;
- }
- List<int> lastBoneSelectionIds
- {
- get;
- }
- Texture2D lastTexture
- {
- get;
- set;
- }
- SerializableDictionary<int, BonePose> lastPreviewPose
- {
- get;
- }
- SerializableDictionary<int, bool> lastBoneVisibility
- {
- get;
- }
- SerializableDictionary<int, bool> lastBoneExpansion
- {
- get;
- }
- SerializableDictionary<string, bool> lastSpriteVisibility
- {
- get;
- }
- SerializableDictionary<int, bool> lastGroupVisibility
- {
- get;
- }
- SkinningMode lastMode
- {
- get;
- set;
- }
- bool lastVisibilityToolActive
- {
- get;
- set;
- }
- int lastVisibilityToolIndex
- {
- get;
- set;
- }
- IndexedSelection lastVertexSelection
- {
- get;
- }
- float lastBrushSize
- {
- get;
- set;
- }
- float lastBrushHardness
- {
- get;
- set;
- }
- float lastBrushStep
- {
- get;
- set;
- }
- }
- [Serializable]
- internal class SkinningCachePersistentState
- : ScriptableSingleton<SkinningCachePersistentState>
- , ISkinningCachePersistentState
- {
- [SerializeField] private Tools m_LastUsedTool = Tools.EditPose;
- [SerializeField] private SkinningMode m_LastMode = SkinningMode.Character;
- [SerializeField] private string m_LastSpriteId = String.Empty;
- [SerializeField] private List<int> m_LastBoneSelectionIds = new List<int>();
- [SerializeField] private Texture2D m_LastTexture;
- [SerializeField]
- private SerializableDictionary<int, BonePose> m_SkeletonPreviewPose =
- new SerializableDictionary<int, BonePose>();
- [SerializeField]
- private SerializableDictionary<int, bool> m_BoneVisibility =
- new SerializableDictionary<int, bool>();
- [SerializeField]
- private SerializableDictionary<int, bool> m_BoneExpansion =
- new SerializableDictionary<int, bool>();
- [SerializeField]
- private SerializableDictionary<string, bool> m_SpriteVisibility =
- new SerializableDictionary<string, bool>();
- [SerializeField]
- private SerializableDictionary<int, bool> m_GroupVisibility =
- new SerializableDictionary<int, bool>();
- [SerializeField] private IndexedSelection m_VertexSelection;
- [SerializeField] private bool m_VisibilityToolActive;
- [SerializeField] private int m_VisibilityToolIndex = -1;
- [SerializeField] private float m_LastBrushSize = 25f;
- [SerializeField] private float m_LastBrushHardness = 1f;
- [SerializeField] private float m_LastBrushStep = 20f;
- public SkinningCachePersistentState()
- {
- m_VertexSelection = new IndexedSelection();
- }
- public void SetDefault()
- {
- m_LastUsedTool = Tools.EditPose;
- m_LastMode = SkinningMode.Character;
- m_LastSpriteId = String.Empty;
- m_LastBoneSelectionIds.Clear();
- m_LastTexture = null;
- m_VertexSelection.Clear();
- m_SkeletonPreviewPose.Clear();
- m_BoneVisibility.Clear();
- m_BoneExpansion.Clear();
- m_SpriteVisibility.Clear();
- m_GroupVisibility.Clear();
- m_VisibilityToolActive = false;
- m_VisibilityToolIndex = -1;
- }
- public string lastSpriteId
- {
- get { return m_LastSpriteId; }
- set { m_LastSpriteId = value; }
- }
- public Tools lastUsedTool
- {
- get { return m_LastUsedTool; }
- set { m_LastUsedTool = value; }
- }
- public List<int> lastBoneSelectionIds
- {
- get { return m_LastBoneSelectionIds; }
- }
- public Texture2D lastTexture
- {
- get { return m_LastTexture; }
- set
- {
- if (value != m_LastTexture)
- {
- m_LastMode = SkinningMode.Character;
- m_LastSpriteId = String.Empty;
- m_LastBoneSelectionIds.Clear();
- m_VertexSelection.Clear();
- m_SkeletonPreviewPose.Clear();
- m_BoneVisibility.Clear();
- m_BoneExpansion.Clear();
- m_SpriteVisibility.Clear();
- m_GroupVisibility.Clear();
- }
- m_LastTexture = value;
- }
- }
- public SerializableDictionary<int, BonePose> lastPreviewPose
- {
- get { return m_SkeletonPreviewPose; }
- }
- public SerializableDictionary<int, bool> lastBoneVisibility
- {
- get { return m_BoneVisibility; }
- }
- public SerializableDictionary<int, bool> lastBoneExpansion
- {
- get { return m_BoneExpansion; }
- }
- public SerializableDictionary<string, bool> lastSpriteVisibility
- {
- get { return m_SpriteVisibility; }
- }
- public SerializableDictionary<int, bool> lastGroupVisibility
- {
- get { return m_GroupVisibility; }
- }
- public SkinningMode lastMode
- {
- get { return m_LastMode; }
- set { m_LastMode = value; }
- }
- public bool lastVisibilityToolActive
- {
- get { return m_VisibilityToolActive; }
- set { m_VisibilityToolActive = value; }
- }
- public int lastVisibilityToolIndex
- {
- get { return m_VisibilityToolIndex; }
- set { m_VisibilityToolIndex = value; }
- }
- public IndexedSelection lastVertexSelection
- {
- get { return m_VertexSelection; }
- }
- public float lastBrushSize
- {
- get { return m_LastBrushSize; }
- set { m_LastBrushSize = value; }
- }
- public float lastBrushHardness
- {
- get { return m_LastBrushHardness; }
- set { m_LastBrushHardness = value; }
- }
- public float lastBrushStep
- {
- get { return m_LastBrushStep; }
- set { m_LastBrushStep = value; }
- }
- }
- }
|