Example #1
0
        /// <summary>
        /// Draw the atlas and Image selection fields.
        /// </summary>

        protected void SpriteGUI()
        {
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.BeginHorizontal();
            //图集
            if (SUGUIEditorTool.DrawPrefixButton("Atlas"))
            {
                AtlasSelector.ShowWind(SelectAtlas);
            }
            SUGUIEditorTool.DrawObjectField <SpriteAtlas>(m_SpriteAtlas, "");
            EditorGUILayout.EndHorizontal();

            SUGUIEditorTool.DrawAtlasSpriteField(m_SpriteAtlas.objectReferenceValue as SpriteAtlas,
                                                 m_SpriteName.stringValue, SelectSprite);
            if (EditorGUI.EndChangeCheck())
            {
                var newSprite = m_Sprite.objectReferenceValue as Sprite;
                if (newSprite)
                {
                    Image.Type oldType = (Image.Type)m_Type.enumValueIndex;
                    if (newSprite.border.SqrMagnitude() > 0)
                    {
                        m_Type.enumValueIndex = (int)Image.Type.Sliced;
                    }
                    else if (oldType == Image.Type.Sliced)
                    {
                        m_Type.enumValueIndex = (int)Image.Type.Simple;
                    }
                }
                (serializedObject.targetObject as Image).DisableSpriteOptimizations();
            }
        }
Example #2
0
        public static void ShowWind(Action <SpriteAtlas> selectAtlas)
        {
            AtlasSelector window = DisplayWizard <AtlasSelector>("图集选择");

            window.minSize = new Vector2(800, 500);

            window.SelectAtlasFunc = selectAtlas;
        }