コード例 #1
0
ファイル: AHMainWindow.cs プロジェクト: Hengle/U_Utility
        private static AHMainWindow initializeWindow()
        {
            m_IntialGUIColor = GUI.color;

            m_window = EditorWindow.GetWindow <AHMainWindow>();
            m_window.Show();
            loadEditorResources();

            m_window.m_BuildLogExists = AHHelper.HasBuildLogAvaliable();

            return(m_window);
        }
コード例 #2
0
ファイル: AHMainWindow.cs プロジェクト: Hengle/U_Utility
        private void showDefaultBody()
        {
            EditorGUILayout.BeginVertical();

            //Draw excluded types foldout
            if (bShowExcludeFoldout)
            {
                GUILayout.Label("-------------------------------------------------------------------------");
                if (settings.HasDirectoryExcludes())
                {
                    GUI.color             = AHHelper.AH_BLUE;
                    EditorGUI.indentLevel = 1;
                    EditorGUILayout.LabelField("Excluded Directories", EditorStyles.whiteBoldLabel);
                    GUI.color             = m_IntialGUIColor;
                    EditorGUI.indentLevel = 2;
                    foreach (UnityEngine.Object obj in settings.m_DirectoryExcludes)
                    {
                        EditorGUILayout.LabelField(AssetDatabase.GetAssetPath(obj), EditorStyles.miniLabel);
                    }
                }
                if (settings.HasTypeExcludes())
                {
                    GUI.color             = AHHelper.AH_BLUE;
                    EditorGUI.indentLevel = 1;
                    EditorGUILayout.LabelField("Excluded Types", EditorStyles.whiteBoldLabel);
                    GUI.color             = m_IntialGUIColor;
                    EditorGUI.indentLevel = 2;
                    foreach (AHSerializableSystemType sType in settings.m_AssetTypeExcludes)
                    {
                        EditorGUILayout.LabelField(sType.Name);
                    }
                }
                if (settings.HasSubStringExcludes())
                {
                    GUI.color             = AHHelper.AH_BLUE;
                    EditorGUI.indentLevel = 1;
                    EditorGUILayout.LabelField("Excluded Strings", EditorStyles.whiteBoldLabel);
                    GUI.color             = m_IntialGUIColor;
                    EditorGUI.indentLevel = 2;
                    foreach (string substring in settings.m_AssetSubstringExcludes)
                    {
                        EditorGUILayout.LabelField(substring);
                    }
                }
                GUILayout.Label("-------------------------------------------------------------------------");
                GUILayout.Space(10);
            }

            //If there is no valid build log
            if (!m_BuildLogExists)
            {
                m_BuildLogExists = AHHelper.HasBuildLogAvaliable();

                if (!m_BuildLogExists)
                {
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Label(m_UIWarning);
                    GUILayout.Label("Asset Helper needs a recent build in order to work", EditorStyles.boldLabel);
                    EditorGUILayout.EndHorizontal();

                    GUILayout.Label("Create a build (Ctrl+Shift+B)");

                    //requires unity 5 to work
                    if (GUILayout.Button("Open Build Settings"))
                    {
                        EditorWindow.GetWindow(Type.GetType("UnityEditor.BuildPlayerWindow,UnityEditor"));
                    }

                    GUILayout.FlexibleSpace();
                    return;
                }
            }

            string buildLogButtonText;

            EditorGUI.indentLevel = 0;
            EditorGUILayout.EndVertical();

            GUILayout.Label("-------------------------------Build Info--------------------------------");

            //If build log up to date
            if (!m_newBuildReady)
            {
                buildLogButtonText = m_BuildLogLoaded ? "Log updated (refresh)" : "Load Build Log (Required)";
                GUI.color          = m_BuildLogLoaded ? AHHelper.AH_GREEN : AHHelper.AH_RED;
            }

            //If build log outdated
            else
            {
                buildLogButtonText = "Log outdated(Refresh)";
                GUI.color          = AHHelper.AH_YELLOW1;
            }

            //Load the Editor build log
            if (GUILayout.Button(buildLogButtonText, GUILayout.Width(375)))
            {
                loadEditorLog();
                return;
            }
            //GUILayout.FlexibleSpace();
            EditorGUILayout.Space();

            GUILayout.Label("------------------------------Select Mode------------------------------");
            EditorGUILayout.BeginHorizontal();

            //Choose window state
            GUI.color = (m_WindowState == AHWindowState.UnusedAssets) ? AHHelper.AH_GREY : m_IntialGUIColor;
            if (GUILayout.Button(AHWindowState.UnusedAssets.ToString(), GUILayout.MinWidth(btnMinWidth)))
            {
                changeState(AHWindowState.UnusedAssets);
            }
            EditorGUILayout.Space();

            GUI.color = (m_WindowState == AHWindowState.BuildReport) ? AHHelper.AH_GREY : m_IntialGUIColor;
            if (GUILayout.Button(AHWindowState.BuildReport.ToString(), GUILayout.MinWidth(btnMinWidth)))
            {
                //Shot buildreport
                changeState(AHWindowState.BuildReport);
            }

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            #region scriptdetection

            /*EditorGUILayout.BeginHorizontal();
             *
             * GUI.color = AHHelper.AH_RED;
             * if (GUILayout.Button(AHWindowState.UnusedScripts.ToString() + " (WIP - USE WITH CONSIDERATION)", GUILayout.MinWidth(btnMinWidth * 2 + 14)))
             * {
             *
             *  GUI.color = m_IntialGUIColor;
             *  //Get added scripts
             *  //List<Type> scriptAssemblyTypes = AHHelper.GetScriptAssembly();
             *
             *  //Find all enabled scenes in buildsettings
             *  EditorBuildSettingsScene[] activeScenes = EditorBuildSettings.scenes.Where(val => val.enabled == true).ToArray<EditorBuildSettingsScene>();
             *
             *
             *  //All script dependencies for all enabled levels in buildsettings
             *  m_UsedScriptList = AHHelper.GetScriptLevelDependencies(activeScenes);
             *
             *  //Find ALL scripts in scriptAssembly
             *  //TODO ADD THIS TO ATTEMPT TO LOCATE UNUSED CODE
             *  //m_UnusedScriptList = AHHelper.GetAddedComponents();
             *
             *  //Remove "Used Scripts" from list
             *  m_UnusedScriptList.RemoveAll(val => m_UsedScriptList.Contains(val));
             *
             *  changeState(AHWindowState.UnusedScripts);
             * }
             *
             * GUILayout.FlexibleSpace();
             * EditorGUILayout.EndHorizontal();
             * EditorGUILayout.Space();*/

            #endregion

            //Reset GUI Color
            GUI.color = m_IntialGUIColor;
        }