Пример #1
0
    protected override void DrawCustomIconsUI()
    {
        EditorGUILayout.LabelField("Atlas Settings", EditorStyles.boldLabel);
        m.atlas = (NJGAtlas)EditorGUILayout.ObjectField("Atlas", m.atlas, typeof(NJGAtlas), false);

        mFolderObject = EditorGUILayout.ObjectField("Sprites Folder", AssetDatabase.LoadAssetAtPath(m.iconFolder, typeof(UnityEngine.Object)), typeof(UnityEngine.Object), false);
        if (mFolderObject != null)
        {
            mFolder = AssetDatabase.GetAssetPath(mFolderObject);

            bool valid = !mFolder.Contains(".");

            string folderName = mFolder.Substring(mFolder.LastIndexOf('/')).Replace('/', ' ').Trim();

            GUI.backgroundColor = valid ? Color.cyan : Color.red;
            if (valid)
            {
                if (m.iconFolder != mFolder)
                {
                    m.iconFolder = mFolder;
                    Save(true);
                }
                GUI.backgroundColor = m.atlas != null ? Color.green : Color.cyan;
                if (GUILayout.Button(m.atlas != null ? "Update Atlas" : "Create Atlas"))
                {
                    if (m.atlas != null)
                    {
                        NJGEditorTools.UpdateAtlas(m.atlas, m.iconFolder + "/");
                    }
                    else
                    {
                        m.atlas = NJGEditorTools.CreateAtlas(m.iconFolder + "/", folderName);
                        Save(true);
                    }
                }
                GUI.backgroundColor = Color.white;
                EditorGUILayout.HelpBox(m.iconFolder, MessageType.Info);
            }
            else
            {
                EditorGUILayout.HelpBox("INVALID! You must select a folder", MessageType.Error);
            }
            GUI.backgroundColor = Color.white;
        }
        else
        {
            GUI.backgroundColor = Color.yellow;
            EditorGUILayout.HelpBox("Drag your icon folder here", MessageType.Warning);
            GUI.backgroundColor = Color.white;
        }
        //GUILayout.EndHorizontal();
        NJGEditorTools.DrawSeparator();
    }