Пример #1
0
        public override void OnGUI(string searchContext)
        {
            DrawInfo();

            EditorGUILayout.Separator();
            EditorGUILayoutUtils.HorizontalLine(2f, 0.95f);

            for (int i = 0; i < m_settingsItems.Count; i++)
            {
                ISettingsItem settingsItem = m_settingsItems[i];

                EditorGUILayoutUtils.RichLabelField(string.Format("<b>{0}</b>", settingsItem.Name));

                using (new EditorGUI.IndentLevelScope())
                {
                    settingsItem.OnGUI();
                }

                if (i < m_settingsItems.Count - 1)
                {
                    EditorGUILayout.Separator();
                    EditorGUILayoutUtils.HorizontalLine(1f, 0.85f);
                }
            }
        }
Пример #2
0
        public override void OnInspectorGUI()
        {
            _propertyCancelOlder = serializedObject.FindProperty(PROPERTY_NAME_CANCEL_OLDER);
            _propertyFader       = serializedObject.FindProperty(PROPERTY_NAME_FADER);
            _propertySceneLoader = serializedObject.FindProperty(PROPERTY_NAME_SCENE_LOADER);

            serializedObject.Update();
            OnInspectorGUIObjectField();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                EditorGUILayout.Space();
                EditorGUILayoutUtils.LabelField("Scylla Scene Management == SceneLoaderProxy", TextAnchor.MiddleCenter, FontStyle.Bold);
                EditorGUILayout.Space();
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.indentLevel++;
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(_propertyCancelOlder, new GUIContent("Cancel older requests"));
            EditorGUILayout.PropertyField(_propertyFader, new GUIContent("Fader"));
            EditorGUILayout.PropertyField(_propertySceneLoader, new GUIContent("Scene loader proxy"));
            EditorGUILayout.Space();
            EditorGUI.indentLevel--;
            EditorGUILayout.EndVertical();

            serializedObject.ApplyModifiedProperties();
        }
        public override void OnInspectorGUI()
        {
            Type signalType = EditorGUILayoutUtils.DrawTypePopup(m_SignalName, SignalEditorUtils.SignalTypes);

            foreach (SerializedProperty serializedProperty in m_Fields)
            {
                AnalyticsFieldEditor.DrawAnalyticsField(serializedProperty, signalType);
            }

            serializedObject.ApplyModifiedProperties();
        }
Пример #4
0
        public static void DrawAnalyticsField(SerializedProperty serializedProperty, Type signalType)
        {
            SerializedProperty useConstant      = serializedProperty.FindPropertyRelative("m_UseConstant");
            SerializedProperty value            = serializedProperty.FindPropertyRelative("m_Value");
            SerializedProperty argumentIndex    = serializedProperty.FindPropertyRelative("m_ArgumentIndex");
            SerializedProperty argumentProperty = serializedProperty.FindPropertyRelative("m_ArgumentProperty");

            EditorGUILayout.BeginVertical("box");
            EditorGUILayout.LabelField($":: {serializedProperty.displayName} ::", EditorStyles.centeredGreyMiniLabel);

            Type baseType      = signalType.BaseType;
            int  argumentCount = baseType.GenericTypeArguments.Length;

            if (argumentCount > 1)
            {
                EditorGUILayout.PropertyField(useConstant);
            }
            else
            {
                useConstant.boolValue = true;
            }

            if (useConstant.boolValue)
            {
                EditorGUILayout.PropertyField(value);
            }
            else
            {
                Type argumentType = EditorGUILayoutUtils.DrawSignalArgumentsPopup(argumentIndex, signalType);

                if (argumentType != null)
                {
                    BindingFlags bindingFlags  = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
                    Type         parentType    = serializedProperty.serializedObject.targetObject.GetType();
                    FieldInfo    typeFieldInfo = parentType.GetField(serializedProperty.propertyPath, bindingFlags);
                    Type         fieldType     = typeFieldInfo.FieldType;
                    PropertyInfo propertyInfo  =
                        fieldType.GetProperty("FieldTypes", BindingFlags.Static | BindingFlags.Public);
                    var fieldTypes = (Type[])propertyInfo.GetValue(null);

                    EditorGUILayoutUtils.DrawPropertyPopup(argumentProperty, argumentType, fieldTypes, bindingFlags);
                }
            }

            EditorGUILayout.EndVertical();
        }
Пример #5
0
        private static void DrawInfo()
        {
            using (new GUIColorScope(new Color(0.6f, 0.6f, 0.6f)))
            {
                EditorGUILayoutUtils.RichLabelField("<b>Atlas Utility Library</b> by David Knopp");
                EditorGUILayout.LabelField(string.Format("Version {0}", Version.Full));
            }

            EditorGUILayout.BeginHorizontal(GUILayout.Width(300f));

            if (GUILayout.Button("View documentation"))
            {
                Application.OpenURL("https://david-knopp.github.io/Atlas/index.html");
            }

            if (GUILayout.Button("View on Github"))
            {
                Application.OpenURL("https://github.com/david-knopp/Atlas");
            }

            EditorGUILayout.EndHorizontal();
        }
Пример #6
0
        public override void OnInspectorGUI()
        {
            _loader = target as SceneLoader;
            _propertyMinLoadingTime = serializedObject.FindProperty(PROPERTY_NAME_MIN_LOADING_TIME);

            serializedObject.Update();
            OnInspectorGUIObjectField();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                EditorGUILayout.Space();
                EditorGUILayoutUtils.LabelField("Scylla Scene Management == SceneLoader", TextAnchor.MiddleCenter, FontStyle.Bold);
                EditorGUILayout.Space();
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.indentLevel++;
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(_propertyMinLoadingTime, new GUIContent("Minimum loading time"));
            EditorGUILayout.Space();
            EditorGUI.indentLevel--;
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                EditorGUILayout.Space();

                EditorGUI.indentLevel++;
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(EditorGUI.indentLevel * 15 + 4);
                _datas.FoldoutDebug = EditorGUILayout.BeginFoldoutHeaderGroup(_datas.FoldoutDebug, "Debug");
                GUILayout.Space(4);
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();

                if (_datas.FoldoutDebug)
                {
                    if (_loader.Collection != null)
                    {
                        var list = _loader.Collection.GetAllScenes(true);
                        for (var i = 0; i < list.Count; i++)
                        {
                            InternalSceneData scene = list[i];

                            EditorGUILayout.BeginVertical();

                            EditorGUILayout.BeginHorizontal();
                            GUILayout.Label(scene.SceneName, GUILayout.Width(180));
                            GUILayout.Label(scene.IsMainScene ? "Main Scene" : "Not main scene", GUILayout.Width(105));
                            GUILayout.Label(scene.IsMarked ? "Marked" : "Not marked", GUILayout.Width(105));
                            GUILayout.Label(scene.IsSuppressible ? "Suppressible" : "Not suppressible",
                                            GUILayout.Width(105));
                            EditorGUILayout.EndHorizontal();

                            EditorGUILayout.BeginHorizontal();
                            GUILayout.Label(scene.BundleIdentifier, GUILayout.Width(180));
                            GUILayout.Label(scene.IsBundleMain ? "Bundle main" : "Not bundle main",
                                            GUILayout.Width(105));
                            EditorGUILayout.EndHorizontal();

                            EditorGUILayout.EndVertical();

                            if (i < list.Count - 1)
                            {
                                EditorGUI.indentLevel--;
                                EditorGUILayoutUtils.HorizontalSeparator();
                                EditorGUI.indentLevel++;
                            }
                        }
                    }

                    /*EditorGUILayout.BeginHorizontal();
                     * {
                     *  GUILayout.Space(EditorGUI.indentLevel * 15 + 4);
                     *
                     * }
                     * EditorGUILayout.EndHorizontal();*/
                }

                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndVertical();

            serializedObject.ApplyModifiedProperties();
        }
Пример #7
0
        private void OnInspectorGUIAutoGenerateSection()
        {
            bool canAutoGenerateEnumeration = true;

            // Drawing header Scylla's scene management
            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                EditorGUILayout.Space();
                EditorGUILayoutUtils.LabelField("Scylla Scene Management == SceneManager", TextAnchor.MiddleCenter, FontStyle.Bold);
                EditorGUILayout.Space();
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            // Drawing fields property
            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUI.indentLevel++;
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(_propertySceneLoader, new GUIContent("Scene loader proxy"));
            EditorGUILayout.PropertyField(_propertyLoadSceneAtStart, new GUIContent("Load scene at start"));
            if (_propertyLoadSceneAtStart.boolValue == true)
            {
                EditorGUILayout.PropertyField(_propertySceneToLoadAtStartName, new GUIContent("Scene name"));
                EditorGUILayout.PropertyField(_propertySceneToLoadAtStartIsMarked, new GUIContent("Scene is marked"));
                EditorGUILayout.PropertyField(_propertySceneToLoadAtStartIsSuppressible, new GUIContent("Scene is suppressible"));
                EditorGUILayout.PropertyField(_propertySceneToLoadAtStartBundleIdentifier, new GUIContent("Scene bundle identifier"));
            }
            EditorGUILayout.Space();
            EditorGUI.indentLevel--;
            EditorGUILayout.EndVertical();


            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                EditorGUILayoutUtils.LabelField("Builds settings & Management", TextAnchor.MiddleCenter, FontStyle.Bold);

                EditorGUILayout.Space();

                EditorGUI.indentLevel++;

                // BUILDS SETTINGS VISUALIZER
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(EditorGUI.indentLevel * 15 + 4);
                _datas.FoldoutBuildSettingsVisualizer = EditorGUILayout.BeginFoldoutHeaderGroup(_datas.FoldoutBuildSettingsVisualizer, "Builds Settings visualizer");
                GUILayout.Space(4);
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();

                if (_datas.FoldoutBuildSettingsVisualizer)
                {
                    for (var i = 0; i < EditorBuildSettings.scenes.Length; i++)
                    {
                        EditorBuildSettingsScene scene = EditorBuildSettings.scenes[i];
                        bool sceneEnabled = scene.enabled;
                        bool sceneDeleted = File.Exists(scene.path) == false;

                        EditorGUILayout.BeginHorizontal();
                        {
                            string textIncluded = "";
                            Color  color        = Color.white;

                            if (sceneDeleted)
                            {
                                textIncluded = "Deleted";
                                color        = Color.black;
                            }
                            else if (sceneEnabled)
                            {
                                textIncluded = "Included";
                                color        = Color.green;
                            }
                            else
                            {
                                textIncluded = "Not included";
                                color        = Color.red;
                            }

                            EditorGUILayout.LabelField("Scene : " + i, System.IO.Path.GetFileNameWithoutExtension(scene.path));
                            EditorGUILayoutUtils.LabelField(textIncluded, color, new GUILayoutOption[] { GUILayout.Width(120) }, TextAnchor.MiddleRight);
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }
                EditorGUILayout.EndFoldoutHeaderGroup();

                EditorGUILayout.Space();

                // BUILDS SETTINGS MANAGEMENT
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(EditorGUI.indentLevel * 15 + 4);
                _datas.FoldoutBuildSettingsManagement = EditorGUILayout.BeginFoldoutHeaderGroup(_datas.FoldoutBuildSettingsManagement, "Builds Settings Management");
                GUILayout.Space(4);
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();

                if (_datas.FoldoutBuildSettingsManagement)
                {
                    // Button to delete from build settings deleted scenes
                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.Space(EditorGUI.indentLevel * 15 + 4);
                        if (GUILayout.Button("Delete deleted's scene in Build Settings"))
                        {
                            EditorBuildSettingsScene[]      originalScenes = EditorBuildSettings.scenes;
                            List <EditorBuildSettingsScene> withoutDeleted = new List <EditorBuildSettingsScene>(originalScenes);
                            withoutDeleted.RemoveAll(scene => File.Exists(scene.path) == false);
                            EditorBuildSettings.scenes = withoutDeleted.ToArray();
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUILayout.EndFoldoutHeaderGroup();

                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                EditorGUILayoutUtils.LabelField("Enumeration auto-generation section", TextAnchor.MiddleCenter, FontStyle.Bold);

                // Auto-generation enum
                EditorGUILayout.Space();

                EditorGUI.indentLevel++;
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(EditorGUI.indentLevel * 15 + 4);
                _datas.FoldoutAutoGenerationSettings = EditorGUILayout.BeginFoldoutHeaderGroup(_datas.FoldoutAutoGenerationSettings, "Auto-generation settings");
                GUILayout.Space(4);
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();

                if (_datas.FoldoutAutoGenerationSettings)
                {
                    EditorGUILayout.BeginVertical();
                    {
                        EditorGUILayout.BeginHorizontal();
                        {
                            GUI.enabled = false;
                            EditorGUILayout.TextField(new GUIContent("Auto-generated folder"), _datas.EnumerationFolderGeneration);
                            GUI.enabled = true;
                            if (GUILayout.Button("Browse", GUILayout.Width(60)))
                            {
                                string path = EditorUtility.OpenFolderPanel("Select auto-generated files's folder", Application.dataPath, _datas.EnumerationFolderGeneration);
                                _datas.EnumerationFolderGeneration = path;
                                serializedObject.ApplyModifiedProperties();
                                Repaint();
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                        EditorGUI.BeginChangeCheck();
                        _datas.EnumerationName      = EditorGUILayout.TextField(new GUIContent("Enumeration name"), _datas.EnumerationName);
                        _datas.EnumerationNamespace = EditorGUILayout.TextField(new GUIContent("Enumeration namespace"), _datas.EnumerationNamespace);
                        _datas.EnumerationFileName  = EditorGUILayout.TextField(new GUIContent("Enumeration file name"), _datas.EnumerationFileName);
                        if (EditorGUI.EndChangeCheck())
                        {
                            Debug.Log("Bool exists : " + HasType(_datas.EnumerationName, _datas.EnumerationNamespace));
                        }
                    }
                    EditorGUILayout.EndVertical();
                }
                EditorGUILayout.EndFoldoutHeaderGroup();

                EditorGUILayout.Space();

                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(EditorGUI.indentLevel * 15 + 4);
                _datas.FoldoutAutoGenerationGenerate = EditorGUILayout.BeginFoldoutHeaderGroup(_datas.FoldoutAutoGenerationGenerate, "Auto-generation");
                GUILayout.Space(4);
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();

                if (_datas.FoldoutAutoGenerationGenerate)
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        if (string.IsNullOrEmpty(_datas.EnumerationFolderGeneration))
                        {
                            EditorGUILayout.HelpBox("Auto-generated folder cannot be empty", MessageType.Error);
                            canAutoGenerateEnumeration = false;
                        }
                        else if (string.IsNullOrEmpty(_datas.EnumerationFileName))
                        {
                            EditorGUILayout.HelpBox("Auto-generated enumeration filename cannot be empty", MessageType.Error);
                            canAutoGenerateEnumeration = false;
                        }
                        else if (string.IsNullOrEmpty(_datas.EnumerationName))
                        {
                            EditorGUILayout.HelpBox("Auto-generated enumeration name cannot be empty", MessageType.Error);
                            canAutoGenerateEnumeration = false;
                        }
                        else
                        {
                            canAutoGenerateEnumeration = true;
                            GUILayout.Space(EditorGUI.indentLevel * 15 + 4);
                            if (GUILayout.Button("Generate"))
                            {
                                GenerateEnumeration();
                            }
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }

                EditorGUILayout.EndFoldoutHeaderGroup();
                EditorGUILayout.Space();
            }

            EditorGUILayout.EndVertical();
            EditorGUI.indentLevel--;

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                EditorGUILayoutUtils.LabelField("Scene auto-generation section", TextAnchor.MiddleCenter, FontStyle.Bold);

                EditorGUILayout.Space();

                EditorGUI.indentLevel++;
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(EditorGUI.indentLevel * 15 + 4);
                _datas.FoldoutAutoGenerationSceneGlobalSettings = EditorGUILayout.BeginFoldoutHeaderGroup(_datas.FoldoutAutoGenerationSceneGlobalSettings, "Auto-generation settings");
                GUILayout.Space(4);
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();

                if (_datas.FoldoutAutoGenerationSceneGlobalSettings)
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        GUI.enabled = false;
                        EditorGUILayout.TextField(new GUIContent("Scene auto-generated folder"), _datas.SceneFolderGeneration);
                        GUI.enabled = true;
                        if (GUILayout.Button("Browse", GUILayout.Width(60)))
                        {
                            string path = EditorUtility.OpenFolderPanel("Select auto-generated files's folder", Application.dataPath, _datas.SceneFolderGeneration);
                            _datas.SceneFolderGeneration = path;
                            serializedObject.ApplyModifiedProperties();
                            Repaint();
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                    _datas.SceneAddToBuild = EditorGUILayout.Toggle(new GUIContent("Add scene to build settings"), _datas.SceneAddToBuild);
                    if (_datas.SceneAddToBuild)
                    {
                        _datas.RegenerateEnum = EditorGUILayout.Toggle(new GUIContent("Regenerate scenes enumeration"), _datas.RegenerateEnum);
                    }
                    else
                    {
                        _datas.RegenerateEnum = false;
                    }
                }

                EditorGUILayout.EndFoldoutHeaderGroup();

                EditorGUILayout.Space();

                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(EditorGUI.indentLevel * 15 + 4);
                _datas.FoldoutAutoGenerationSceneSettings = EditorGUILayout.BeginFoldoutHeaderGroup(_datas.FoldoutAutoGenerationSceneSettings, "Auto-generation scene settings");
                GUILayout.Space(4);
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();

                if (_datas.FoldoutAutoGenerationSceneSettings)
                {
                    _datas.SceneName = EditorGUILayout.TextField(new GUIContent("Scene name"), _datas.SceneName);
                }

                EditorGUILayout.EndFoldoutHeaderGroup();

                EditorGUILayout.Space();

                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(EditorGUI.indentLevel * 15 + 4);
                _datas.FoldoutAutoGenerationSceneGenerate = EditorGUILayout.BeginFoldoutHeaderGroup(_datas.FoldoutAutoGenerationSceneGenerate, "Auto-generation settings");
                GUILayout.Space(4);
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();

                if (_datas.FoldoutAutoGenerationSceneGenerate)
                {
                    if (string.IsNullOrEmpty(_datas.SceneFolderGeneration))
                    {
                        EditorGUILayout.HelpBox("Scene auto-generated folder cannot be empty", MessageType.Error);
                    }
                    else if (string.IsNullOrEmpty(_datas.SceneName))
                    {
                        EditorGUILayout.HelpBox("Scene auto-generated name cannot be empty", MessageType.Error);
                    }
                    else if (_datas.RegenerateEnum && canAutoGenerateEnumeration == false)
                    {
                        EditorGUILayout.HelpBox("Can't regenerate enum when auto-generation enumeration has issues", MessageType.Error);
                    }
                    else
                    {
                        EditorGUILayout.BeginHorizontal();
                        {
                            GUILayout.Space(EditorGUI.indentLevel * 15 + 4);
                            if (GUILayout.Button("Generate"))
                            {
                                string relativeFolderPath = "";

                                if (_datas.SceneFolderGeneration.StartsWith(Application.dataPath))
                                {
                                    relativeFolderPath = "Assets" + _datas.SceneFolderGeneration.Substring(Application.dataPath.Length);
                                }

                                UnityEngine.SceneManagement.Scene scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Additive);
                                scene.name = _datas.SceneName;
                                string     relativePath  = Path.Combine(relativeFolderPath, scene.name + ".unity");
                                GameObject scyllaSceneGO = new GameObject("ScyllaScene");
                                scyllaSceneGO.AddComponent(typeof(ScyllaScene));
                                EditorSceneManager.SaveScene(scene, relativePath);
                                EditorSceneManager.CloseScene(scene, true);

                                if (_datas.SceneAddToBuild)
                                {
                                    EditorBuildSettingsScene[] originalScenes = EditorBuildSettings.scenes;
                                    EditorBuildSettingsScene[] newScenes      = new EditorBuildSettingsScene[originalScenes.Length + 1];
                                    Array.Copy(originalScenes, newScenes, originalScenes.Length);

                                    EditorBuildSettingsScene sceneToAdd = new EditorBuildSettingsScene(relativePath, true);
                                    newScenes[newScenes.Length - 1] = sceneToAdd;
                                    EditorBuildSettings.scenes      = newScenes;
                                }

                                if (_datas.RegenerateEnum)
                                {
                                    GenerateEnumeration();
                                }
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }

                EditorGUILayout.EndFoldoutHeaderGroup();
            }

            EditorGUILayout.Space();
            EditorGUILayout.EndVertical();
        }