示例#1
0
        public override void OnInspectorGUI()
        {
            ((Component)this.target).transform.hideFlags = HideFlags.HideInInspector;

            GUILayoutExt.CollectEditors <IDebugViewGUIEditor <InitializerBase>, ViewProviderCustomEditorAttribute>(ref this.viewsDebugEditors);
            GUILayoutExt.CollectEditors <IJobsViewGUIEditor <InitializerBase>, ViewProviderCustomEditorAttribute>(ref this.viewsJobsEditors);

            var target = this.target as InitializerBase;

            if (target.featuresList == null)
            {
                target.featuresList = new FeaturesList();
            }
            if (target.featuresList.features == null)
            {
                target.featuresList.features = new System.Collections.Generic.List <FeaturesList.FeatureData>();
            }

            if (this.list == null)
            {
                this.list = new UnityEditorInternal.ReorderableList(target.featuresList.features, typeof(FeaturesList.FeatureData), true, true, true, true);
                this.list.drawElementCallback   = this.OnDrawListItem;
                this.list.drawHeaderCallback    = this.OnDrawHeader;
                this.list.onChangedCallback     = this.OnChanged;
                this.list.elementHeightCallback = this.GetElementHeight;
            }

            GUILayoutExt.Box(15f, 0f, () => {
                var isDirty = false;

                this.definesFoldOut = GUILayoutExt.BeginFoldoutHeaderGroup(this.definesFoldOut, new GUIContent("Defines"), EditorStyles.foldoutHeader);
                if (this.definesFoldOut == true)
                {
                    GUILayout.Space(10f);

                    EditorGUI.BeginDisabledGroup(EditorApplication.isCompiling == true || EditorApplication.isPlaying == true || EditorApplication.isPaused == true /* || InitializerEditor.isCompilingManual == true*/);

                    foreach (var defineInfo in InitializerEditor.defines)
                    {
                        if (defineInfo.showInList == false)
                        {
                            continue;
                        }

                        var value = defineInfo.isActive.Invoke();
                        if (GUILayoutExt.ToggleLeft(
                                ref value,
                                ref isDirty,
                                defineInfo.define,
                                defineInfo.description) == true)
                        {
                            //InitializerEditor.isCompilingManual = true;

                            if (value == true)
                            {
                                this.CompileWithDefine(defineInfo.define);
                            }
                            else
                            {
                                this.CompileWithoutDefine(defineInfo.define);
                            }
                        }
                    }

                    EditorGUI.EndDisabledGroup();
                }

                this.settingsFoldOut = GUILayoutExt.BeginFoldoutHeaderGroup(this.settingsFoldOut, new GUIContent("Settings"), EditorStyles.foldoutHeader);
                if (this.settingsFoldOut == true)
                {
                    GUILayout.Space(10f);

                    GUILayoutExt.ToggleLeft(
                        ref target.worldSettings.turnOffViews,
                        ref isDirty,
                        "Turn off views module",
                        "If you want to run ME.ECS on server, you don't need to use Views at all. Turn off views module to avoid updating view instances overhead.");

                    GUILayoutExt.ToggleLeft(
                        ref target.worldSettings.useJobsForSystems,
                        ref isDirty,
                        "Use jobs for Systems",
                        "Each system with filter has `jobs` flag which determine AdvanceTick behavior. If checked, jobs will be enabled and AdvanceTick will run asynchronously.");

                    GUILayoutExt.ToggleLeft(
                        ref target.worldSettings.useJobsForViews,
                        ref isDirty,
                        "Use jobs for Views",
                        "Some view providers have jobs implementation. Turn it on to enable them update views inside jobs. Please note that some providers could lose some method calls.");

                    if (this.viewsJobsEditors != null)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Space(10f);
                        {
                            GUILayout.BeginVertical();
                            foreach (var editor in this.viewsJobsEditors)
                            {
                                GUILayoutExt.Separator();
                                editor.Value.target = this.target as InitializerBase;
                                if (editor.Value.OnDrawGUI() == true)
                                {
                                    isDirty = true;
                                }
                            }
                            GUILayout.EndVertical();
                        }
                        GUILayout.EndHorizontal();
                    }
                }

                this.settingsDebugFoldOut = GUILayoutExt.BeginFoldoutHeaderGroup(this.settingsDebugFoldOut, new GUIContent("Debug Settings"), EditorStyles.foldoutHeader);
                if (this.settingsDebugFoldOut == true)
                {
                    GUILayout.Space(10f);

                    GUILayoutExt.ToggleLeft(
                        ref target.worldDebugSettings.createGameObjectsRepresentation,
                        ref isDirty,
                        "Create GameObject representation",
                        "Editor-only feature. If checked, all entities will be represented by GameObject with debug information.");

                    GUILayoutExt.ToggleLeft(
                        ref target.worldDebugSettings.showViewsOnScene,
                        ref isDirty,
                        "Show Views in Hierarchy",
                        "Editor-only feature. If checked, views module always show views on scene.");

                    if (this.viewsDebugEditors != null)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Space(10f);
                        {
                            GUILayout.BeginVertical();
                            foreach (var editor in this.viewsDebugEditors)
                            {
                                GUILayoutExt.Separator();
                                editor.Value.target = this.target as InitializerBase;
                                if (editor.Value.OnDrawGUI() == true)
                                {
                                    isDirty = true;
                                }
                            }
                            GUILayout.EndVertical();
                        }
                        GUILayout.EndHorizontal();
                    }
                }

                {
                    var editor = Editor.CreateEditor(target);
                    var field  = editor.serializedObject.GetIterator();
                    editor.serializedObject.Update();
                    var baseClassEnd = false;
                    while (field.NextVisible(true) == true)
                    {
                        if (baseClassEnd == true)
                        {
                            EditorGUILayout.PropertyField(field);
                        }

                        if (field.type == "EndOfBaseClass")
                        {
                            baseClassEnd = true;
                        }
                    }

                    editor.serializedObject.ApplyModifiedProperties();
                }

                if (isDirty == true)
                {
                    EditorUtility.SetDirty(this.target);
                }
            });

            EditorGUILayout.Space();

            EditorGUI.BeginDisabledGroup(EditorApplication.isPlaying == true || EditorApplication.isPaused == true);
            this.drawWidth = GUILayoutUtility.GetLastRect().width;
            this.list.DoLayoutList();
            EditorGUI.EndDisabledGroup();
        }