Inheritance: SpriteUtilityWindow
Exemplo n.º 1
0
        private void OnDisable()
        {
            Undo.undoRedoPerformed -= UndoRedoPerformed;
            HandleApplyRevertDialog(SpriteEditorWindowStyles.applyRevertDialogTitle.text,
                                    String.Format(SpriteEditorWindowStyles.applyRevertDialogContent.text, m_SelectedAssetPath));
            InvalidatePropertiesCache();
            EditorApplication.modifierKeysChanged -= ModifierKeysChanged;
            s_Instance = null;

            if (m_OutlineTexture != null)
            {
                DestroyImmediate(m_OutlineTexture);
                m_OutlineTexture = null;
            }

            if (m_ReadableTexture)
            {
                DestroyImmediate(m_ReadableTexture);
                m_ReadableTexture = null;
            }

            if (m_CurrentModule != null)
            {
                m_CurrentModule.OnModuleDeactivate();
            }
        }
        void OnEnable()
        {
            minSize      = new Vector2(360, 200);
            titleContent = SpriteEditorWindowStyles.spriteEditorWindowTitle;
            s_Instance   = this;

            m_UndoSystem.RegisterUndoCallback(UndoRedoPerformed);
            EditorApplication.modifierKeysChanged  += ModifierKeysChanged;
            EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
            EditorApplication.quitting             += OnEditorApplicationQuit;

            if (selectedProviderChanged)
            {
                m_SelectedAssetPath = GetSelectionAssetPath();
            }

            ResetWindow();
            RefreshPropertiesCache();
            bool noSelectedSprite = string.IsNullOrEmpty(m_SelectedSpriteRectGUID);

            RefreshRects();
            if (noSelectedSprite)
            {
                UpdateSelectedSpriteRectFromSelection();
            }

            SetupVisualElements();
            InitModules();
        }
Exemplo n.º 3
0
 static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
 {
     foreach (var importedAsset in importedAssets)
     {
         SpriteEditorWindow.OnTextureReimport(importedAsset);
     }
 }
Exemplo n.º 4
0
        public override void OnInspectorGUI()
        {
            DoTilePreview(tile.sprite, tile.color, Matrix4x4.identity);

            serializedObject.Update();

            EditorGUILayout.PropertyField(m_Sprite);

            using (new EditorGUI.DisabledGroupScope(m_Sprite.objectReferenceValue == null))
            {
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button(Styles.spriteEditorLabel))
                {
                    Selection.activeObject = m_Sprite.objectReferenceValue;
                    SpriteEditorWindow.GetWindow();
                }
                GUILayout.EndHorizontal();
            }

            EditorGUILayout.PropertyField(m_Color);
            EditorGUILayout.PropertyField(m_ColliderType);

            serializedObject.ApplyModifiedProperties();
        }
 private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
 {
     for (int i = 0; i < importedAssets.Length; i++)
     {
         string path = importedAssets[i];
         SpriteEditorWindow.OnTextureReimport(path);
     }
 }
 void OnEnable()
 {
     minSize      = new Vector2(360, 200);
     titleContent = SpriteEditorWindowStyles.spriteEditorWindowTitle;
     s_Instance   = this;
     m_UndoSystem.RegisterUndoCallback(UndoRedoPerformed);
     EditorApplication.modifierKeysChanged += ModifierKeysChanged;
     ResetWindow();
     RefreshPropertiesCache();
     RefreshRects();
     InitModules();
 }
Exemplo n.º 7
0
 private void OnEnable()
 {
     base.minSize                  = new Vector2(360f, 200f);
     base.titleContent             = SpriteEditorWindow.SpriteEditorWindowStyles.spriteEditorWindowTitle;
     SpriteEditorWindow.s_Instance = this;
     this.m_UndoSystem.RegisterUndoCallback(new Undo.UndoRedoCallback(this.UndoRedoPerformed));
     EditorApplication.modifierKeysChanged = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.modifierKeysChanged, new EditorApplication.CallbackFunction(this.ModifierKeysChanged));
     this.ResetWindow();
     this.RefreshPropertiesCache();
     this.RefreshRects();
     this.InitModules();
 }
Exemplo n.º 8
0
 private void OnDisable()
 {
     Undo.undoRedoPerformed = (Undo.UndoRedoCallback)Delegate.Remove(Undo.undoRedoPerformed, new Undo.UndoRedoCallback(this.UndoRedoPerformed));
     if (this.m_RectsCache != null)
     {
         Undo.ClearUndo(this.m_RectsCache);
     }
     this.HandleApplyRevertDialog();
     this.InvalidatePropertiesCache();
     EditorApplication.modifierKeysChanged = (EditorApplication.CallbackFunction)Delegate.Remove(EditorApplication.modifierKeysChanged, new EditorApplication.CallbackFunction(this.ModifierKeysChanged));
     SpriteEditorWindow.s_Instance         = null;
     if (this.m_OutlineTexture != null)
     {
         UnityEngine.Object.DestroyImmediate(this.m_OutlineTexture);
         this.m_OutlineTexture = null;
     }
     if (this.m_ReadableTexture)
     {
         UnityEngine.Object.DestroyImmediate(this.m_ReadableTexture);
         this.m_ReadableTexture = null;
     }
 }
Exemplo n.º 9
0
 private void OnDisable()
 {
     Undo.undoRedoPerformed = (Undo.UndoRedoCallback)Delegate.Remove(Undo.undoRedoPerformed, new Undo.UndoRedoCallback(this.UndoRedoPerformed));
     this.HandleApplyRevertDialog(SpriteEditorWindow.SpriteEditorWindowStyles.applyRevertDialogTitle.text, string.Format(SpriteEditorWindow.SpriteEditorWindowStyles.applyRevertDialogContent.text, this.m_SelectedAssetPath));
     this.InvalidatePropertiesCache();
     EditorApplication.modifierKeysChanged = (EditorApplication.CallbackFunction)Delegate.Remove(EditorApplication.modifierKeysChanged, new EditorApplication.CallbackFunction(this.ModifierKeysChanged));
     SpriteEditorWindow.s_Instance         = null;
     if (this.m_OutlineTexture != null)
     {
         UnityEngine.Object.DestroyImmediate(this.m_OutlineTexture);
         this.m_OutlineTexture = null;
     }
     if (this.m_ReadableTexture)
     {
         UnityEngine.Object.DestroyImmediate(this.m_ReadableTexture);
         this.m_ReadableTexture = null;
     }
     if (this.m_CurrentModule != null)
     {
         this.m_CurrentModule.OnModuleDeactivate();
     }
 }
 private void OnDisable()
 {
   Undo.undoRedoPerformed -= new Undo.UndoRedoCallback(this.UndoRedoPerformed);
   if ((UnityEngine.Object) this.m_RectsCache != (UnityEngine.Object) null)
     Undo.ClearUndo((UnityEngine.Object) this.m_RectsCache);
   this.HandleApplyRevertDialog();
   this.InvalidatePropertiesCache();
   EditorApplication.modifierKeysChanged -= new EditorApplication.CallbackFunction(this.ModifierKeysChanged);
   SpriteEditorWindow.s_Instance = (SpriteEditorWindow) null;
 }
Exemplo n.º 11
0
		public void DoAutomaticSlicing(int minimumSpriteSize, int alignment, SpriteEditorWindow.AutoSlicingMethod slicingMethod)
		{
			Undo.RegisterCompleteObjectUndo(this.m_RectsCache, "Automatic Slicing");
			if (slicingMethod == SpriteEditorWindow.AutoSlicingMethod.DeleteAll)
			{
				this.m_RectsCache.ClearAll();
			}
			List<Rect> list = new List<Rect>(InternalSpriteUtility.GenerateAutomaticSpriteRectangles(this.m_Texture, minimumSpriteSize, 0));
			list = this.SortRects(list);
			foreach (Rect current in list)
			{
				this.AddSprite(current, alignment, slicingMethod);
			}
			this.selected = null;
			this.textureIsDirty = true;
			base.Repaint();
		}
Exemplo n.º 12
0
 private void OnEnable()
 {
     base.minSize = new Vector2(360f, 200f);
     base.titleContent = EditorGUIUtility.TextContent("Sprite Editor");
     s_Instance = this;
     Undo.undoRedoPerformed = (Undo.UndoRedoCallback) Delegate.Combine(Undo.undoRedoPerformed, new Undo.UndoRedoCallback(this.UndoRedoPerformed));
     EditorApplication.modifierKeysChanged = (EditorApplication.CallbackFunction) Delegate.Remove(EditorApplication.modifierKeysChanged, new EditorApplication.CallbackFunction(this.ModifierKeysChanged));
     EditorApplication.modifierKeysChanged = (EditorApplication.CallbackFunction) Delegate.Combine(EditorApplication.modifierKeysChanged, new EditorApplication.CallbackFunction(this.ModifierKeysChanged));
     this.Reset();
 }
Exemplo n.º 13
0
 private void OnDisable()
 {
     Undo.undoRedoPerformed = (Undo.UndoRedoCallback) Delegate.Remove(Undo.undoRedoPerformed, new Undo.UndoRedoCallback(this.UndoRedoPerformed));
     if (this.m_RectsCache != null)
     {
         Undo.ClearUndo(this.m_RectsCache);
     }
     this.HandleApplyRevertDialog();
     this.InvalidatePropertiesCache();
     EditorApplication.modifierKeysChanged = (EditorApplication.CallbackFunction) Delegate.Remove(EditorApplication.modifierKeysChanged, new EditorApplication.CallbackFunction(this.ModifierKeysChanged));
     s_Instance = null;
 }
Exemplo n.º 14
0
		private void AddSprite(Rect frame, int alignment, SpriteEditorWindow.AutoSlicingMethod slicingMethod)
		{
			if (slicingMethod != SpriteEditorWindow.AutoSlicingMethod.DeleteAll)
			{
				SpriteRect existingOverlappingSprite = this.GetExistingOverlappingSprite(frame);
				if (existingOverlappingSprite != null)
				{
					if (slicingMethod == SpriteEditorWindow.AutoSlicingMethod.Smart)
					{
						existingOverlappingSprite.m_Rect = frame;
						existingOverlappingSprite.m_Alignment = (SpriteAlignment)alignment;
					}
				}
				else
				{
					this.AddSprite(frame, alignment, this.defaultColliderAlphaCutoff, this.defaultColliderDetail);
				}
			}
			else
			{
				this.AddSprite(frame, alignment, this.defaultColliderAlphaCutoff, this.defaultColliderDetail);
			}
		}
 static private void OpenSpriteEditorWindow()
 {
     SpriteEditorWindow.GetWindow();
 }
 private void OnEnable()
 {
   this.minSize = new Vector2(360f, 200f);
   this.titleContent = EditorGUIUtility.TextContent("Sprite Editor");
   SpriteEditorWindow.s_Instance = this;
   Undo.undoRedoPerformed += new Undo.UndoRedoCallback(this.UndoRedoPerformed);
   EditorApplication.modifierKeysChanged -= new EditorApplication.CallbackFunction(this.ModifierKeysChanged);
   EditorApplication.modifierKeysChanged += new EditorApplication.CallbackFunction(this.ModifierKeysChanged);
   this.Reset();
 }
 private void AddSprite(Rect frame, int alignment, Vector2 pivot, SpriteEditorWindow.AutoSlicingMethod slicingMethod)
 {
   if (slicingMethod != SpriteEditorWindow.AutoSlicingMethod.DeleteAll)
   {
     SpriteRect overlappingSprite = this.GetExistingOverlappingSprite(frame);
     if (overlappingSprite != null)
     {
       if (slicingMethod != SpriteEditorWindow.AutoSlicingMethod.Smart)
         return;
       overlappingSprite.m_Rect = frame;
       overlappingSprite.m_Alignment = (SpriteAlignment) alignment;
       overlappingSprite.m_Pivot = pivot;
     }
     else
       this.AddSprite(frame, alignment, pivot, this.defaultColliderAlphaCutoff, this.defaultColliderDetail);
   }
   else
     this.AddSprite(frame, alignment, pivot, this.defaultColliderAlphaCutoff, this.defaultColliderDetail);
 }
 public void DoAutomaticSlicing(int minimumSpriteSize, int alignment, Vector2 pivot, SpriteEditorWindow.AutoSlicingMethod slicingMethod)
 {
   Undo.RegisterCompleteObjectUndo((UnityEngine.Object) this.m_RectsCache, "Automatic Slicing");
   if (slicingMethod == SpriteEditorWindow.AutoSlicingMethod.DeleteAll)
     this.m_RectsCache.ClearAll();
   using (List<Rect>.Enumerator enumerator = this.SortRects(new List<Rect>((IEnumerable<Rect>) InternalSpriteUtility.GenerateAutomaticSpriteRectangles(this.m_Texture, minimumSpriteSize, 0))).GetEnumerator())
   {
     while (enumerator.MoveNext())
       this.AddSprite(enumerator.Current, alignment, pivot, slicingMethod);
   }
   this.selected = (SpriteRect) null;
   this.textureIsDirty = true;
   this.Repaint();
 }
Exemplo n.º 19
0
		private void OnDisable()
		{
			Undo.undoRedoPerformed = (Undo.UndoRedoCallback)Delegate.Remove(Undo.undoRedoPerformed, new Undo.UndoRedoCallback(this.UndoRedoPerformed));
			this.HandleApplyRevertDialog();
			this.InvalidatePropertiesCache();
			SpriteEditorWindow.s_Instance = null;
		}
Exemplo n.º 20
0
		private void OnEnable()
		{
			base.minSize = new Vector2(360f, 200f);
			base.title = EditorGUIUtility.TextContent("SpriteEditorWindow.WindowTitle").text;
			SpriteEditorWindow.s_Instance = this;
			Undo.undoRedoPerformed = (Undo.UndoRedoCallback)Delegate.Combine(Undo.undoRedoPerformed, new Undo.UndoRedoCallback(this.UndoRedoPerformed));
			this.Reset();
		}