예제 #1
0
        private static void DrawAdvancedSpriteField(AtlasTexture atlas, string spriteName)
        {
            if (atlas == null)
            {
                return;
            }

            if (atlas.Sprites.Count == 0)
            {
                EditorGUILayout.HelpBox("No sprites found", MessageType.Warning);
                return;
            }

            GUILayout.BeginHorizontal();
            {
                if (EditorLayoutTools.DrawPrefixButton("Sprite"))
                {
                    EditorAtlasPrefs.atlas          = atlas;
                    EditorAtlasPrefs.selectedSprite = spriteName;
                    AtlasSpriteSelector.Show(SelectSprite);
                }

                EditorGUILayout.SelectableLabel(spriteName, new GUIStyle("TextArea"), GUILayout.Height(18f));
            }
            GUILayout.EndHorizontal();
        }
예제 #2
0
        private AtlasAction DrawButtons()
        {
            var action = AtlasAction.None;

            GUILayout.Space(5f);

            using (new EditorGUILayout.HorizontalScope())
            {
                GUI.backgroundColor = Color.cyan;

                GUILayout.FlexibleSpace();

                if (GUILayout.Button("Apply", GUILayout.Width(150f)))
                {
                    action |= AtlasAction.Update;
                }

                GUI.backgroundColor = defaultBackgroundColor;

                GUILayout.Space(25f);

                if (GUILayout.Button("View Sprites", GUILayout.Width(150f)))
                {
                    AtlasSpriteSelector.ShowSelected();
                }

                GUILayout.FlexibleSpace();
            }

            GUILayout.Space(5f);

            return(action);
        }
예제 #3
0
        public static void Show(Callback callback)
        {
            if (instance != null)
            {
                instance.Close();
                instance = null;
            }

            var comp = ScriptableWizard.DisplayWizard <AtlasSpriteSelector>("Select Sprite");

            comp.callback = callback;
        }
예제 #4
0
        private void CustomInspector()
        {
            EditorGUILayout.Separator();

            EditorGUI.BeginChangeCheck();

            var atlasTexture = (AtlasTexture)EditorGUILayout.ObjectField("AtlasTexture", atlasTextureImage.Atlas, typeof(AtlasTexture), false);

            if (EditorGUI.EndChangeCheck())
            {
                UnityEditorUtility.RegisterUndo("AtlasTextureImage Undo", instance.atlasTextureImage);
                Reflection.SetPrivateField(atlasTextureImage, "atlas", atlasTexture);
            }

            if (atlasTextureImage.Atlas != null)
            {
                EditorGUILayout.Separator();

                if (atlasTextureImage.Atlas.Sprites.Any())
                {
                    using (new GUILayout.HorizontalScope())
                    {
                        if (EditorLayoutTools.DrawPrefixButton("Sprite"))
                        {
                            EditorAtlasPrefs.atlas          = atlasTextureImage.Atlas;
                            EditorAtlasPrefs.selectedSprite = atlasTextureImage.SpriteName;
                            AtlasSpriteSelector.Show(SelectSprite);
                        }

                        if (!string.IsNullOrEmpty(atlasTextureImage.SpriteName))
                        {
                            EditorGUILayout.SelectableLabel(atlasTextureImage.SpriteName, EditorStyles.textArea, GUILayout.Height(18f));
                        }
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("No sprites found", MessageType.Warning);
                }
            }

            EditorGUILayout.Separator();
        }
예제 #5
0
 void OnDisable()
 {
     instance = null;
 }
예제 #6
0
 void OnEnable()
 {
     instance = this;
 }