Foldout() private method

private Foldout ( bool foldout, GUIContent content ) : bool
foldout bool
content UnityEngine.GUIContent
return bool
        void DrawActionButtonArrayElement(SP dialog, int elementIndex)
        {
            DrawArrayElement(dialog, elementIndex, "Consent dialog should have at least 1 button.", MinActionButtonsCount,
                             () => SelectedButtonIndex,
                             param => SelectedButtonIndex = param,
                             obj =>
            {
                var title = obj.FindPropertyRelative("title");

                EditorGUI.indentLevel++;
                string key = obj.propertyPath;

                if (!privacyFoldoutStates.ContainsKey(key))
                {
                    privacyFoldoutStates.Add(key, false);
                }

                string titleValue         = !string.IsNullOrEmpty(title.stringValue) ? title.stringValue : "[Untitled Button]";
                privacyFoldoutStates[key] = EGL.Foldout(privacyFoldoutStates[key], titleValue, true);
                EditorGUI.indentLevel--;

                if (privacyFoldoutStates[key])
                {
                    EGL.PropertyField(obj.FindPropertyRelative("id"));
                    EGL.PropertyField(title);
                    EGL.PropertyField(obj.FindPropertyRelative("interactable"));
                    EGL.PropertyField(obj.FindPropertyRelative("titleColor"));
                    EGL.PropertyField(obj.FindPropertyRelative("backgroundColor"));
                    EGL.PropertyField(obj.FindPropertyRelative("uninteractableTitleColor"));
                    EGL.PropertyField(obj.FindPropertyRelative("uninteractableBackgroundColor"));
                }
            });
        }
        /// <summary>
        /// Draws the resizable array.
        /// </summary>
        /// <param name="arrayProperty">Array property.</param>
        /// <param name="drawElement">Action to draw target property.</param>
        /// <param name="updateNewElement">
        /// Action to update new element's values
        /// so it won't have same values with the previous one when created.
        /// </param>
        bool DrawResizableArray(SP arrayProperty, bool foldout, string foldoutLabel, Action <SP, int> drawElement, Action <SP> updateNewElement = null, bool noLabel = false, int maxSize = int.MaxValue)
        {
            /// Draw array name and a button to add new element into array.
            GUILayout.BeginHorizontal();

            EditorGUI.indentLevel++;
            foldout = EGL.Foldout(foldout, noLabel ? "" : foldoutLabel, true);
            EditorGUI.indentLevel--;

            GUIContent      plusButtonContent  = EditorGUIUtility.IconContent("Toolbar Plus");
            GUIStyle        plusButtonStyle    = GUIStyle.none;
            GUILayoutOption plusButtonMinWidth = GUILayout.MaxWidth(E_SM.smallButtonWidth);

            if (GUILayout.Button(plusButtonContent, plusButtonStyle, plusButtonMinWidth) && arrayProperty.arraySize < maxSize)
            {
                arrayProperty.arraySize++;

                /// Update new property so it won't have same values with the previous one.
                if (updateNewElement != null)
                {
                    updateNewElement(arrayProperty.GetArrayElementAtIndex(arrayProperty.arraySize - 1));
                }

                /// We should expand the array so user can see
                /// the element that has just been added.
                foldout = true;
            }
            GUILayout.EndHorizontal();

            /// Draw all array's elements.
            if (!foldout || arrayProperty.arraySize <= 0)
            {
                return(foldout);
            }

            for (int i = 0; i < arrayProperty.arraySize; i++)
            {
                drawElement(arrayProperty, i);
                if (i < arrayProperty.arraySize - 1)
                {
                    EGL.Space();
                }
            }

            EGL.Space();
            return(foldout);
        }
示例#3
0
    void showBuildingGUI()
    {
        EG.BeginDisabledGroup(!roadMeshGenerated);
        // General Terrain Settings
        showBuildingUI = EGL.Foldout(showBuildingUI, buildingLabel, true);
        if (showBuildingUI)
        {
            /*if (GL.Button("Generate blocks"))
             * {
             * generator.generateBlocks();
             * }*/

            if (GL.Button("Generate Buildings"))
            {
                generator.generateBuildings();
                buildingLabel = "5. Building Generation - COMPLETED ✔";
            }
            CG.generateWindows = EGL.ToggleLeft("Generate Windows", CG.generateWindows);
        }
        EG.EndDisabledGroup();
    }
        void DrawToggleArrayElement(SP dialog, int elementIndex)
        {
            DrawArrayElement(dialog, elementIndex, "", MinTogglesCount,
                             () => SelectedToggleIndex,
                             param => SelectedToggleIndex = param,
                             obj =>
            {
                var shouldToggleContent = new GUIContent("Toggle Description", "Change description when toggle is updated.");
                var shouldToggleOnDescriptionContent = new GUIContent("Toggle On Description",
                                                                      "This description will be displayed if the toggle value is true.");
                var shouldToggleOffDescriptionContent = new GUIContent("Description",
                                                                       "This description will be displayed regardless of the toggle value.");
                var offDescriptionContent = new GUIContent("Toggle Off Description",
                                                           "This description will be displayed if the toggle value is false.");

                var title = obj.FindPropertyRelative("title");

                string key = obj.propertyPath;
                if (!privacyFoldoutStates.ContainsKey(key))
                {
                    privacyFoldoutStates.Add(key, false);
                }

                EditorGUI.indentLevel++;
                string titleValue         = !string.IsNullOrEmpty(title.stringValue) ? title.stringValue : "[Untitled Toggle]";
                privacyFoldoutStates[key] = EGL.Foldout(privacyFoldoutStates[key], titleValue, true);
                EditorGUI.indentLevel--;

                if (privacyFoldoutStates[key])
                {
                    EGL.PropertyField(obj.FindPropertyRelative("id"));
                    EGL.PropertyField(title);
                    EGL.PropertyField(obj.FindPropertyRelative("isOn"));
                    EGL.PropertyField(obj.FindPropertyRelative("interactable"));

                    var shouldToggle = obj.FindPropertyRelative("shouldToggleDescription");
                    EGL.PropertyField(shouldToggle, shouldToggleContent);

                    // On description.
                    var onDescription         = obj.FindPropertyRelative("onDescription");
                    onDescription.stringValue = EGL.TextField(
                        shouldToggle.boolValue ? shouldToggleOnDescriptionContent : shouldToggleOffDescriptionContent,
                        onDescription.stringValue,
                        new GUIStyle(ES.textField)
                    {
                        wordWrap = true
                    },
                        GUILayout.Height(EditorGUIUtility.singleLineHeight * 3));

                    if (shouldToggle.boolValue)
                    {
                        var offDescription         = obj.FindPropertyRelative("offDescription");
                        offDescription.stringValue = EGL.TextField(
                            offDescriptionContent,
                            offDescription.stringValue,
                            new GUIStyle(ES.textField)
                        {
                            wordWrap = true
                        },
                            GUILayout.Height(EditorGUIUtility.singleLineHeight * 3));
                    }
                }
            });
        }
示例#5
0
        void InspectBehaviourList(List <StateBehaviour> list)
        {
            using (new EGL.HorizontalScope()) {
                EGL.LabelField("Behaviours", EditorStyles.boldLabel);
                GL.FlexibleSpace();
                var listHash = list.GetHashCode();
                if (GL.Button("+", GL.Width(30)) &&
                    popupRects.ContainsKey(listHash))
                {
                    PopupWindow.Show(popupRects[listHash], new AddBehaviourPopup(state.profile, list));
                }

                if (Event.current.type == EventType.Repaint)
                {
                    popupRects.Remove(listHash);
                    popupRects.Add(listHash, GUILayoutUtility.GetLastRect());
                }
            }
            for (int i = 0; i < list.Count; ++i)
            {
                var behaviour = list[i];
                var active    = activeBehaviours.Contains(behaviour);

                if (!behaviour)
                {
                    list.RemoveAt(i);
                    --i;
                    continue;
                }

                EGL.BeginHorizontal();
                active = EGL.Foldout(active, behaviour.name);
                if (GL.Button("-", GL.Width(30)))
                {
                    DestroyImmediate(behaviour, true);
                    list.RemoveAt(i);
                    --i;
                }
                EGL.EndHorizontal();

                if (!behaviour)
                {
                    continue;
                }

                if (active)
                {
                    activeBehaviours.Add(behaviour);
                }
                else
                {
                    activeBehaviours.Remove(behaviour);
                }

                if (active)
                {
                    ++EditorGUI.indentLevel;
                    GetBehaviorEditor(behaviour).OnInspectorGUI();
                    --EditorGUI.indentLevel;
                }
            }

            if (GUI.enabled)
            {
                GL.BeginHorizontal();
                GL.FlexibleSpace();


                GL.FlexibleSpace();
                GL.EndHorizontal();
            }
        }
示例#6
0
        public override void OnInspectorGUI()
        {
            bool targetChanged = false;

            if (target != state)
            {
                addStatePortionName = "";
                targetChanged       = true;
            }
            state = (State)target;

            if (targetChanged)
            {
                var layer     = state.profile.controller.layers[state.profile.controllerLayer];
                var animState = Utils.FindState(layer.stateMachine, state.stateName);
                clip = animState.motion as AnimationClip;

                var sb = new System.Text.StringBuilder();

                var events = AnimationUtility.GetAnimationEvents(clip);
                sb.AppendFormat("Events ({0}) ", events.Length).AppendLine();
                if (events.Length > 0)
                {
                    foreach (var ev in events)
                    {
                        sb.Append(string.Format("{0,4}", (int)FrameUtil.Time2Frame(ev.time))).Append("F ");
                        sb.Append(ev.functionName);
                        sb.AppendLine();
                    }
                }
                sb.AppendLine();

                var bindings = AnimationUtility.GetCurveBindings(clip);
                sb.AppendFormat("Bindings ({0})", bindings.Length).AppendLine();
                foreach (var binding in bindings)
                {
                    sb.Append("  ").Append(binding.path).Append(binding.path == "" ? "" : "/")
                    .Append("<").Append(binding.type.Name).Append(">.")
                    .Append(binding.propertyName).AppendLine();
                }

                summary = sb.ToString();
            }

            EditorGUI.BeginChangeCheck();

            EGL.LabelField("Name", state.stateName);
            EGL.LabelField("Frames", state.frames.ToString());

            bool lastGUIEnabled = GUI.enabled;

            GUI.enabled = false;
            EGL.ObjectField("Clip", clip, typeof(AnimationClip), allowSceneObjects: false);
            GUI.enabled = lastGUIEnabled;

            if (summary.Length > 0)
            {
                EGL.HelpBox(summary, MessageType.None);
            }

            state.tags = InspectTags(state.tags);
            EGL.Space();

            using (new EGL.VerticalScope(EditorStyles.helpBox)) {
                ++EditorGUI.indentLevel;
                InspectBehaviourList(state.behaviours);
                --EditorGUI.indentLevel;
                EGL.Space();
            }

            EGL.LabelField("Portions");
            var portions = state.portions;

            for (int i = 0; i < portions.Count; ++i)
            {
                var portion = portions[i];

                bool active = activePortions.Contains(portion);
                active = EGL.Foldout(active, portion.name);
                if (active)
                {
                    activePortions.Add(portion);
                }
                else
                {
                    activePortions.Remove(portion);
                }

                if (active)
                {
                    ++EditorGUI.indentLevel;

                    EGL.BeginHorizontal();
                    portion.name = EGL.TextField("Name", portion.name);
                    // GL.FlexibleSpace();
                    if (GL.Button("-", GUILayout.Width(30)))
                    {
                        portions.RemoveAt(i);
                        --i;
                    }
                    EGL.EndHorizontal();

                    portion.range      = EditorGUIUtil.FrameRangeSlider("Range", portion.range, state.frames);
                    portion.includeEnd = EGL.Toggle("Include nt>=1", portion.includeEnd);
                    portion.tags       = InspectTags(portion.tags);

                    using (new EGL.VerticalScope(EditorStyles.helpBox)) {
                        InspectBehaviourList(portion.behaviours);
                    }

                    --EditorGUI.indentLevel;
                }
            }

            EGL.Space();
            EGL.Space();
            EGL.BeginHorizontal();
            addStatePortionName = EGL.TextField(addStatePortionName);
            if (GUI.enabled && GL.Button("Add Portion", GL.Width(90)))
            {
                var portion = new StatePortion {
                    name = addStatePortionName
                };
                portions.Add(portion);

                addStatePortionName = "";
            }
            EGL.EndHorizontal();

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(state);
            }
        }
示例#7
0
        private void OnGUI()
        {
            if (settings == null)
            {
                settings = ConstantGenerator.GetSettingsFile();
            }

            if (logo == null)
            {
                logo = ConstantGenerator.GetLogo();
            }

            if (border == null)
            {
                border = ConstantGenerator.GetBorder();
            }

            EditorGUI.BeginChangeCheck();

            StartGUI("Layers");
            if (DrawGenButton())
            {
                LayersGen.Generate();
                window.Close();
            }

            if (DrawForceGenButton())
            {
                LayersGen.ForceGenerate();
                window.Close();
            }
            EndGUI();
            // -------------------------------------------------------------------------------------
            StartGUI("Tags");
            if (DrawGenButton())
            {
                TagsGen.Generate();
                window.Close();
            }

            if (DrawForceGenButton())
            {
                TagsGen.ForceGenerate();
                window.Close();
            }
            EndGUI();
            // -------------------------------------------------------------------------------------
            StartGUI("Sort Layers");
            if (DrawGenButton())
            {
                SortingLayersGen.Generate();
                window.Close();
            }

            if (DrawForceGenButton())
            {
                SortingLayersGen.ForceGenerate();
                window.Close();
            }
            EndGUI();
            // -------------------------------------------------------------------------------------
            StartGUI("Scenes");
            if (DrawGenButton())
            {
                ScenesGen.Generate();
                window.Close();
            }

            if (DrawForceGenButton())
            {
                ScenesGen.ForceGenerate();
                window.Close();
            }
            EndGUI();
            // -------------------------------------------------------------------------------------
            StartGUI("Shader Props");
            if (DrawGenButton())
            {
                ShaderPropsGen.Generate(false);
                window.Close();
            }

            if (DrawForceGenButton())
            {
                ShaderPropsGen.ForceGenerate();
                window.Close();
            }
            EndGUI();
            // -------------------------------------------------------------------------------------
            StartGUI("Anim Params");
            if (DrawGenButton())
            {
                AnimParamsGen.Generate();
                window.Close();
            }

            if (DrawForceGenButton())
            {
                AnimParamsGen.ForceGenerate();
                window.Close();
            }
            EndGUI();
            // -------------------------------------------------------------------------------------
            StartGUI("Anim Layers");
            if (DrawGenButton())
            {
                AnimLayersGen.Generate();
                window.Close();
            }

            if (DrawForceGenButton())
            {
                AnimLayersGen.ForceGenerate();
                window.Close();
            }
            EndGUI();
            // -------------------------------------------------------------------------------------
            StartGUI("Anim States");
            if (DrawGenButton())
            {
                AnimStatesGen.Generate();
                window.Close();
            }

            if (DrawForceGenButton())
            {
                AnimStatesGen.ForceGenerate();
                window.Close();
            }
            EndGUI();
            // -------------------------------------------------------------------------------------
            StartGUI("Nav Areas");
            if (DrawGenButton())
            {
                NavAreasGen.Generate();
                window.Close();
            }

            if (DrawForceGenButton())
            {
                NavAreasGen.ForceGenerate();
                window.Close();
            }
            EndGUI();
            // =========================================================================================
            DrawLine(Color.white, 2, 5);

            GUIStyle style = new GUIStyle(GUI.skin.button);

            style.alignment = TextAnchor.MiddleCenter;
            style.fontStyle = FontStyle.Bold;

            EGL.BeginHorizontal();
            EGL.BeginVertical();
            EGL.BeginHorizontal();
            if (GL.Button("GENERATE ALL", style))
            {
                LayersGen.Generate();
                TagsGen.Generate();
                SortingLayersGen.Generate();
                ScenesGen.Generate();
                ShaderPropsGen.Generate(false);
                AnimParamsGen.Generate();
                AnimLayersGen.Generate();
                AnimStatesGen.Generate();
                window.Close();
            }
            GL.FlexibleSpace();
            EGL.EndHorizontal();

            EGL.BeginHorizontal();
            if (GL.Button("FORCE GENERATE ALL", style))
            {
                LayersGen.ForceGenerate();
                TagsGen.ForceGenerate();
                SortingLayersGen.ForceGenerate();
                ScenesGen.ForceGenerate();
                ShaderPropsGen.ForceGenerate();
                AnimParamsGen.ForceGenerate();
                AnimLayersGen.ForceGenerate();
                AnimStatesGen.ForceGenerate();
                window.Close();
            }
            GL.FlexibleSpace();
            EGL.EndHorizontal();
            EGL.EndVertical();
            EGL.BeginVertical();
            // ---------------------------------------------------------------------------------------
            Color genOnReloadColor;
            Color updateOnReloadColor;

            if (settings.regenerateOnMissing)
            {
                genOnReloadColor = Color.green * 2;
            }
            else
            {
                genOnReloadColor = Color.white * 1.5f;
            }

            if (settings.updateOnReload)
            {
                updateOnReloadColor = Color.green * 2;
            }
            else
            {
                updateOnReloadColor = Color.white * 1.5f;
            }

            EGL.BeginHorizontal();
            GUI.backgroundColor = genOnReloadColor;
            if (GL.Button(new GUIContent("ReGen On Missing", "Automatically re-generates the constants file is none is present."), style))
            {
                settings.regenerateOnMissing = !settings.regenerateOnMissing;
                EditorUtility.SetDirty(settings);
            }
            EGL.EndHorizontal();

            EGL.BeginHorizontal();
            GUI.backgroundColor = updateOnReloadColor;
            if (GL.Button(new GUIContent("Update On Reload", "Automatically re-generates the constants on editor recompile if any changes are detected."), style))
            {
                settings.updateOnReload = !settings.updateOnReload;
                EditorUtility.SetDirty(settings);
            }
            EGL.EndHorizontal();

            EGL.EndVertical();
            EGL.EndHorizontal();
            // =========================================================================================
            DrawLine(Color.white, 2, 5);

            GUI.backgroundColor = Color.gray;
            GUI.contentColor    = Color.white * 10;

// check for unity versions using conditional directives
// NOTE: there is no "BeginFoldoutHeaderGroup" in below 2019.1
 #if UNITY_2019_OR_NEWER
            showFoldOut = EGL.BeginFoldoutHeaderGroup(showFoldOut, "Create Generator Script");
#else
            showFoldOut = EGL.Foldout(showFoldOut, "Create Generator Script");
 #endif
            if (showFoldOut)
            {
                GL.Space(5);
                GUI.contentColor = Color.white * 10;
                generatorName    = EGL.TextField("Generator Name", generatorName);
                outputFileName   = EGL.TextField("Output File Name", outputFileName);

                GL.Space(5);
                EGL.BeginHorizontal();

                if (!settings.regenerateOnMissing)
                {
                    EGL.BeginVertical();
                    GL.FlexibleSpace();
                    EGL.HelpBox("NOTE: Force Generate will only delete the file but will NOT generate a new one if the [ReGen On Missing] is turned off",
                                MessageType.Warning);
                    EGL.EndVertical();
                }
                else
                {       // ============================================================================
                        // Draw Ma Awesome Logo
                    EGL.BeginVertical();
                    GL.FlexibleSpace();
                    Rect horiRect = EGL.BeginHorizontal();

                    Rect boxRect = new Rect(horiRect.x + 3, horiRect.y - 54, 125, 52);

                    Rect backgroundRect = boxRect;
                    backgroundRect.width  = border.width;
                    backgroundRect.height = border.height;
                    GUI.DrawTexture(backgroundRect, border);
                    // GUI.Box( boxRect, iconBackground, );

                    GUI.Label(new Rect(boxRect.x + 3, boxRect.y + 16, 100, 20), "Created BY: ");

                    Rect logoRect = new Rect(boxRect.x + 76, boxRect.y + 2, logo.width, logo.height);
                    GUI.DrawTexture(logoRect, logo);

                    EGL.EndHorizontal();
                    EGL.EndVertical();
                    // ============================================================================
                }

                GL.FlexibleSpace();

                GUI.contentColor = Color.white * 5;
                EGL.BeginVertical();
                GL.FlexibleSpace();
                GUI.backgroundColor = Color.white * 2.5f;
                GUI.contentColor    = Color.black * 5;
                if (GL.Button("Create", new GUIStyle(GUI.skin.button)
                {
                    fontStyle = FontStyle.Bold, fontSize = 12
                },
                              GL.Width(75), GL.Height(30)))
                {
                    if (generatorName == string.Empty || outputFileName == string.Empty || generatorName == null || outputFileName == null)
                    {
                        Debug.LogWarning("Fill out all the fields");
                    }
                    else
                    {
                        TemplateGen.GenerateTemplate(generatorName, outputFileName);
                        window.Close();
                    }
                }
                EGL.EndVertical();
                GL.Space(1);
                EGL.EndHorizontal();
            }

 #if UNITY_2019_OR_NEWER
            EGL.EndFoldoutHeaderGroup();
 #endif

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(settings);
            }
        }
示例#8
0
    void showRoadMapGUI()
    {
        EG.BeginDisabledGroup(!(terrainGenerated && growthMapGenerated && populationGenerated));
        showRoadMapUI = EGL.Foldout(showRoadMapUI, roadmapLabel, true);
        if (showRoadMapUI)
        {
            GL.Label("Streets", EditorStyles.centeredGreyMiniLabel);
            GL.BeginHorizontal();
            GL.BeginVertical();
            GL.Label("Width");
            GL.Label("Min Length");
            GL.Label("LookAhead");
            GL.Label("Pop Threshold");
            GL.Label("Max Slope");
            GL.EndVertical();
            GL.BeginVertical();
            CG.streetWidth        = EGL.IntSlider(CG.streetWidth, 5, 20);
            CG.streetMinLength    = EGL.Slider(CG.streetMinLength, 5f, 100f);
            CG.streetLookAhead    = EGL.IntSlider(CG.streetLookAhead, 1, (int)(CG.terrainSize / CG.streetMinLength));
            CG.streetPopThreshold = EGL.Slider(CG.streetPopThreshold, 0f, 1f);
            CG.streetMaxSlope     = EGL.Slider(CG.streetMaxSlope, 0f, 1f);
            GL.EndVertical();
            GL.EndHorizontal();

            GL.Space(5);

            GL.Label("Highways", EditorStyles.centeredGreyMiniLabel);
            GL.BeginHorizontal();
            GL.BeginVertical();
            GL.Label("Width");
            GL.Label("Min Length");
            GL.Label("LookAhead");
            GL.Label("Pop Threshold");
            GL.Label("Max Slope");
            GL.EndVertical();
            GL.BeginVertical();
            CG.highwayWidth        = EGL.IntSlider(CG.highwayWidth, 10, 25);
            CG.highwayMinLength    = EGL.Slider(CG.highwayMinLength, 5f, 200f);
            CG.highwayLookAhead    = EGL.IntSlider(CG.highwayLookAhead, 1, (int)(CG.terrainSize / CG.highwayMinLength));
            CG.highwayPopThreshold = EGL.Slider(CG.highwayPopThreshold, 0f, 1f);
            CG.highwayMaxSlope     = EGL.Slider(CG.highwayMaxSlope, 0f, 1f);
            GL.EndVertical();
            GL.EndHorizontal();

            GL.Space(10);

            showRoadMapAdvanced = EGL.Foldout(showRoadMapAdvanced, "Advanced Settings", true);
            if (showRoadMapAdvanced)
            {
                EGL.HelpBox("Adjusting these settings might break the Editor or severely influence performance.", MessageType.Warning);
                GL.Label("General Advanced Settings", EditorStyles.centeredGreyMiniLabel);
                GL.BeginHorizontal();
                GL.BeginVertical();
                GL.Label("Legalization Attempts");
                GL.Label("Min Road Correction Angle");
                GL.Label("Node Check Radius");
                GL.Label("Road Connect Max Distance");
                GL.Label("Ray Count");
                GL.EndVertical();
                GL.BeginVertical();
                CG.legalizationAttempts = EGL.IntSlider(CG.legalizationAttempts, 1, 100);
                CG.minRoadAngle         = EGL.IntSlider(CG.minRoadAngle, 0, 90);
                CG.nodeCheckRadius      = EGL.Slider(CG.nodeCheckRadius, 0f, 100f);
                CG.roadConnectDistance  = EGL.Slider(CG.roadConnectDistance, 0f, 100f);
                CG.rayCount             = EGL.IntSlider(CG.rayCount, 1, 32);
                GL.EndVertical();
                GL.EndHorizontal();

                GL.Label("Advanced Settings for L-system Component", EditorStyles.centeredGreyMiniLabel);
                EGL.HelpBox("Low values correspond to higher priority.", MessageType.Info);
                GL.BeginHorizontal();
                GL.BeginVertical();
                GL.Label("Street - Priority");
                GL.Label("Highway - Priority");
                GL.EndVertical();
                GL.BeginVertical();
                CG.streetPriority  = EGL.IntSlider(CG.streetPriority, 1, 5);
                CG.highwayPriority = EGL.IntSlider(CG.highwayPriority, 1, 5);
                GL.EndVertical();
                GL.EndHorizontal();

                GL.Label("Advanced Settings for Growth Rules", EditorStyles.centeredGreyMiniLabel);
                GL.BeginHorizontal();
                GL.BeginVertical();
                GL.Label("Street - Straight Angle");
                GL.Label("Street - Branch  Angle");
                GL.Space(10);
                GL.Label("Highway - Branch Prob");
                GL.Label("Highway - Straight Angle");
                GL.Label("Highway - Branch Angle");
                GL.EndVertical();
                GL.BeginVertical();
                CG.streetStraightAngle = EGL.Slider(CG.streetStraightAngle, 0f, 90f);
                CG.streetBranchAngle   = EGL.Slider(CG.streetBranchAngle, 0f, 90f);
                GL.Space(10);
                CG.highwayBranchProb    = EGL.Slider(CG.highwayBranchProb, 0f, 1f);
                CG.highwayStraightAngle = EGL.Slider(CG.highwayStraightAngle, 0f, 90f);
                CG.highwayBranchAngle   = EGL.Slider(CG.highwayBranchAngle, 0f, 90f);
                GL.EndVertical();
                GL.EndHorizontal();
            }
            if (roadMapGenerated)
            {
                GL.BeginHorizontal("Box");
                GL.FlexibleSpace();
                CG.showPop = EGL.ToggleLeft("Preview Pop Map", CG.showPop);
                GL.FlexibleSpace();
                CG.showGrowth = EGL.ToggleLeft("Preview Growth Map", CG.showGrowth);
                GL.FlexibleSpace();
                GL.EndHorizontal();

                if (DebugMode)
                {
                    showPreviewGUI();
                }
            }
            EGL.HelpBox("The 'Generate Road Map' button may take several tries to generate road map due to the random nature of the algorithm.", MessageType.Info);
            GL.BeginHorizontal();
            if (GL.Button("Generate Road Map"))
            {
                GameObject roadMap = GameObject.Find("RoadMap");
                GameObject nodes   = GameObject.Find("Nodes");


                if (roadMap != null)
                {
                    roadMap.SetActive(true);
                }
                if (nodes != null)
                {
                    nodes.SetActive(true);
                }
                generator.generateRoadMap();
                roadMapGenerated  = true;
                roadMeshGenerated = false;
            }

            EG.BeginDisabledGroup(!roadMapGenerated);
            if (GL.Button("Generate Road Meshes & Blocks"))
            {
                generator.generateRoadMeshes();
                generator.generateBlocks();
                roadMeshGenerated = true;
            }
            EG.EndDisabledGroup();
            GL.EndHorizontal();

            EG.BeginDisabledGroup(!roadMeshGenerated);
            if (GL.Button("Save and Proceed"))
            {
                showRoadMapUI       = false;
                showRoadMapAdvanced = false;
                showBuildingUI      = true;
                GameObject roadMap = GameObject.Find("RoadMap");
                if (roadMap != null)
                {
                    roadMap.SetActive(false);
                }
                GameObject nodes = GameObject.Find("Nodes");
                if (nodes != null)
                {
                    nodes.SetActive(false);
                }
                roadmapLabel = "4. Road Map Generation - COMPLETED ✔";
            }
            EG.EndDisabledGroup();
        }
        EG.EndDisabledGroup();
    }
示例#9
0
    void showGrowthMapGUI()
    {
        EG.BeginDisabledGroup(!(terrainGenerated));
        showGrowthUI = EGL.Foldout(showGrowthUI, growthLabel, true);
        if (showGrowthUI)
        {
            GL.BeginVertical();

            GL.BeginHorizontal();
            GL.BeginVertical();
            if (GL.Button("Basic Rule"))
            {
                CG.growthBasic   = 1;
                CG.growthNewYork = 0;
                CG.growthParis   = 0;
            }
            if (GL.Button("New York Rule"))
            {
                CG.growthNewYork = 1;
                CG.growthBasic   = 0;
                CG.growthParis   = 0;
            }
            if (GL.Button("Paris Rule"))
            {
                CG.growthParis   = 1;
                CG.growthBasic   = 0;
                CG.growthNewYork = 0;
            }
            GL.EndVertical();
            GL.BeginVertical();
            GL.Space(1);
            CG.growthBasic = EGL.Slider(1 - CG.growthNewYork - CG.growthParis, 0, 1);
            GL.Space(1);
            CG.growthNewYork = EGL.Slider(1 - CG.growthBasic - CG.growthParis, 0, 1);
            GL.Space(1);
            CG.growthParis = EGL.Slider(1 - CG.growthBasic - CG.growthNewYork, 0, 1);
            GL.EndVertical();
            GL.EndHorizontal();
            GL.Space(1);

            if (GL.Button("Default"))
            {
                CG.growthParis   = 1f / 3f;
                CG.growthBasic   = 1f / 3f;
                CG.growthNewYork = 1f / 3f;
            }

            GL.BeginHorizontal("box");
            GL.BeginVertical();
            GL.Label("Octaves");
            GL.Label("Persistance");
            GL.Label("Zoom");
            GL.Label("Seed");
            GL.EndVertical();

            GL.BeginVertical();
            CG.growthOctaves     = EGL.IntSlider(CG.growthOctaves, 1, 6);
            CG.growthPersistance = EGL.Slider(CG.growthPersistance, 0, 0.7f);
            CG.growthZoom        = EGL.Slider(CG.growthZoom, 0, 0.05f);
            GL.BeginHorizontal();
            EG.BeginDisabledGroup(rGrowthSeed.target == false);
            CG.growthSeed = EGL.IntSlider(CG.growthSeed, 0, int.MaxValue);
            EG.EndDisabledGroup();
            rGrowthSeed.target = EGL.Toggle(rGrowthSeed.target);
            GL.EndHorizontal();

            GL.Space(20);

            GL.BeginHorizontal();
            GL.Label("Or import your growth-rule map: ");
            CG.growthMapInput = (Texture2D)EGL.ObjectField(CG.growthMapInput, typeof(Texture2D), false);
            GL.EndHorizontal();
            GL.EndVertical();

            GL.EndHorizontal();
            GL.EndVertical();

            GL.BeginHorizontal();
            if (GL.Button("Generate Growth Map"))
            {
                if (rGrowthSeed.target == false && CG.growthMapInput == null)
                {
                    CG.growthSeed = Random.Range(0, int.MaxValue);
                }
                generator.generateGrowthRule();
                isGrowthMap   = true;
                CG.showGrowth = true;
            }

            EG.BeginDisabledGroup(!isGrowthMap);
            GL.BeginHorizontal();
            GL.FlexibleSpace();
            CG.showGrowth = EGL.ToggleLeft("Preview Growth Map", CG.showGrowth);
            GL.FlexibleSpace();
            GL.EndHorizontal();
            GL.EndHorizontal();

            if (GL.Button("Save and Proceed"))
            {
                growthMapGenerated = true;
                growthLabel        = "3. Growth Map Generation - COMPLETED ✔";
                showGrowthUI       = false;
                CG.showGrowth      = false;
                showRoadMapUI      = true;
            }
            EG.EndDisabledGroup();
        }
        EG.EndDisabledGroup();
    }
示例#10
0
    void showPopulationMapGUI()
    {
        EG.BeginDisabledGroup(!(terrainGenerated));
        showPopUI = EGL.Foldout(showPopUI, populationLabel, true);
        if (showPopUI)
        {
            GL.BeginVertical();
            GL.BeginHorizontal("box");
            GL.BeginVertical();
            GL.Label("Octaves");
            GL.Label("Persistance");
            GL.Label("Zoom");
            GL.Label("Seed");
            GL.EndVertical();

            GL.BeginVertical();
            CG.popOctaves     = EGL.IntSlider(CG.popOctaves, 1, 6);
            CG.popPersistance = EGL.Slider(CG.popPersistance, 0, 0.5f);
            CG.popZoom        = EGL.Slider(CG.popZoom, 0, 0.05f);
            GL.BeginHorizontal();
            EG.BeginDisabledGroup(rPopSeed.target == false);
            CG.popSeed = EGL.IntSlider(CG.popSeed, 0, int.MaxValue);
            EG.EndDisabledGroup();
            rPopSeed.target = EGL.Toggle(rPopSeed.target);
            GL.EndHorizontal();

            GL.Space(20);

            GL.BeginHorizontal();
            GL.Label("Or import your custom pop map: ");
            CG.popMapInput = (Texture2D)EGL.ObjectField(CG.popMapInput, typeof(Texture2D), false);
            GL.EndHorizontal();
            GL.EndVertical();

            GL.EndHorizontal();
            GL.EndVertical();

            GL.BeginHorizontal();
            if (GL.Button("Generate Population Map"))
            {
                if (rPopSeed.target == false && CG.popMapInput == null)
                {
                    CG.popSeed = Random.Range(0, int.MaxValue);
                }
                generator.generatePopulationMap();
                isPopMap   = true;
                CG.showPop = true;
            }

            EG.BeginDisabledGroup(!isPopMap);
            GL.BeginHorizontal();
            GL.FlexibleSpace();
            CG.showPop = EGL.ToggleLeft("Preview Pop Map", CG.showPop);
            GL.EndHorizontal();

            GL.EndHorizontal();
            if (GL.Button("Save and Proceed"))
            {
                populationGenerated = true;
                populationLabel     = "2. Population Map Generation - COMPLETED ✔";
                showPopUI           = false;
                CG.showPop          = false;
                showGrowthUI        = true;
            }
            EG.EndDisabledGroup();
        }
        EG.EndDisabledGroup();
    }
示例#11
0
    void showTerrainGUI()
    {
        // General Terrain Settings
        showTerrainUI = EGL.Foldout(showTerrainUI, terrainLabel, true);

        if (showTerrainUI)
        {
            GL.BeginHorizontal();
            GL.BeginVertical();
            GL.Label(new GUIContent("Terrain Size", "The width in units of the generated Terrain Object."));
            GL.Label(new GUIContent("Terrain Height Range", "The min and max height in units of the generated Terrain Object."));
            GL.Label("Water?");
            GL.EndVertical();

            GL.BeginVertical();
            CG.terrainSize = EGL.IntSlider(CG.terrainSize, 512, 2048);
            GL.BeginHorizontal();
            GL.TextField(CG.minHeight.ToString("F1"));
            EGL.MinMaxSlider(ref CG.minHeight, ref CG.maxHeight, CG.terrainSize * -CG.highwayMaxSlope, CG.terrainSize * CG.highwayMaxSlope);
            GL.TextField(CG.maxHeight.ToString("F1"));
            GL.EndHorizontal();
            EG.BeginDisabledGroup(CG.minHeight > 0);
            rWaterToggle.target = EGL.Toggle(rWaterToggle.target);
            EG.EndDisabledGroup();
            GL.EndVertical();
            GL.EndHorizontal();

            GL.BeginVertical();
            GL.Label("Height Map Generation", EditorStyles.centeredGreyMiniLabel);
            GL.BeginHorizontal("box");
            GL.BeginVertical();
            GL.Label("Octaves");
            GL.Label("Persistance");
            GL.Label("Zoom");
            GL.Label("Seed");
            GL.EndVertical();

            GL.BeginVertical();
            CG.terrainOctaves     = EGL.IntSlider(CG.terrainOctaves, 1, 6);
            CG.terrainPersistance = EGL.Slider(CG.terrainPersistance, 0, 0.7f);
            CG.terrainZoom        = EGL.Slider(CG.terrainZoom, 0.01f, 0.04f);
            GL.BeginHorizontal();
            EG.BeginDisabledGroup(rTerrainSeed.target == false);
            CG.terrainSeed = EGL.IntSlider(CG.terrainSeed, 0, int.MaxValue);
            EG.EndDisabledGroup();
            rTerrainSeed.target = EGL.Toggle(rTerrainSeed.target);
            GL.EndHorizontal();
            GL.Space(20);
            GL.BeginHorizontal();
            GL.Label("Or import your custom height map: ");
            CG.terrainMap = (Texture2D)EGL.ObjectField(CG.terrainMap, typeof(Texture2D), false);
            GL.EndHorizontal();
            GL.EndVertical();


            GL.EndHorizontal();
            GL.EndVertical();

            GL.BeginHorizontal();
            if (GL.Button("Generate New Terrain"))
            {
                if (rTerrainSeed.target == false && CG.terrainMap == null)
                {
                    CG.terrainSeed = Random.Range(0, int.MaxValue);
                }
                CG.rWater = rWaterToggle.target;
                generator.generateTerrain();
                isTerrain = true;
            }
            EG.BeginDisabledGroup(!isTerrain);
            if (GL.Button("Save and Proceed"))
            {
                terrainGenerated = true;
                terrainLabel     = "1. Terrain Generation - COMPLETED ✔";
                if (CityGeneratorUI.DebugMode)
                {
                    Debug.Log("Terrain Generated");
                }
                showTerrainUI = false;
                showPopUI     = true;
            }
            EG.EndDisabledGroup();

            GL.EndHorizontal();
        }
    }
示例#12
0
        private void OnGUI()
        {
            int dirtyCount = PhysicsVisualizationSettings.dirtyCount;

            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]);
            PhysicsVisualizationSettings.filterWorkflow = (PhysicsVisualizationSettings.FilterWorkflow)EditorGUILayout.EnumPopup(PhysicsVisualizationSettings.filterWorkflow, EditorStyles.toolbarPopup, new GUILayoutOption[]
            {
                GUILayout.Width(130f)
            });
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Reset", EditorStyles.toolbarButton, new GUILayoutOption[0]))
            {
                PhysicsVisualizationSettings.Reset();
            }
            EditorGUILayout.EndHorizontal();
            this.m_MainScrollPos = GUILayout.BeginScrollView(this.m_MainScrollPos, new GUILayoutOption[0]);
            PhysicsVisualizationSettings.FilterWorkflow filterWorkflow = PhysicsVisualizationSettings.filterWorkflow;
            string str  = (filterWorkflow != PhysicsVisualizationSettings.FilterWorkflow.ShowSelectedItems) ? "Hide " : "Show ";
            int    mask = InternalEditorUtility.LayerMaskToConcatenatedLayersMask(PhysicsVisualizationSettings.GetShowCollisionLayerMask(filterWorkflow));
            int    concatenatedLayersMask = EditorGUILayout.MaskField(GUIContent.Temp(str + "Layers", str + "selected layers"), mask, InternalEditorUtility.layers, new GUILayoutOption[0]);

            PhysicsVisualizationSettings.SetShowCollisionLayerMask(filterWorkflow, InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(concatenatedLayersMask));
            PhysicsVisualizationSettings.SetShowStaticColliders(filterWorkflow, EditorGUILayout.Toggle(GUIContent.Temp(str + "Static Colliders", str + "collision geometry from Colliders that do not have a Rigidbody"), PhysicsVisualizationSettings.GetShowStaticColliders(filterWorkflow), new GUILayoutOption[0]));
            PhysicsVisualizationSettings.SetShowTriggers(filterWorkflow, EditorGUILayout.Toggle(GUIContent.Temp(str + "Triggers", str + "collision geometry from Colliders that have 'isTrigger' enabled"), PhysicsVisualizationSettings.GetShowTriggers(filterWorkflow), new GUILayoutOption[0]));
            PhysicsVisualizationSettings.SetShowRigidbodies(filterWorkflow, EditorGUILayout.Toggle(GUIContent.Temp(str + "Rigidbodies", str + "collision geometry from Rigidbodies"), PhysicsVisualizationSettings.GetShowRigidbodies(filterWorkflow), new GUILayoutOption[0]));
            PhysicsVisualizationSettings.SetShowKinematicBodies(filterWorkflow, EditorGUILayout.Toggle(GUIContent.Temp(str + "Kinematic Bodies", str + "collision geometry from Kinematic Rigidbodies"), PhysicsVisualizationSettings.GetShowKinematicBodies(filterWorkflow), new GUILayoutOption[0]));
            PhysicsVisualizationSettings.SetShowSleepingBodies(filterWorkflow, EditorGUILayout.Toggle(GUIContent.Temp(str + "Sleeping Bodies", str + "collision geometry from Sleeping Rigidbodies"), PhysicsVisualizationSettings.GetShowSleepingBodies(filterWorkflow), new GUILayoutOption[0]));
            this.m_FilterColliderTypesFoldout = EditorGUILayout.Foldout(this.m_FilterColliderTypesFoldout, "Collider Types");
            if (this.m_FilterColliderTypesFoldout)
            {
                EditorGUI.indentLevel++;
                float labelWidth = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = 200f;
                PhysicsVisualizationSettings.SetShowBoxColliders(filterWorkflow, EditorGUILayout.Toggle(GUIContent.Temp(str + "BoxColliders", str + "collision geometry from BoxColliders"), PhysicsVisualizationSettings.GetShowBoxColliders(filterWorkflow), new GUILayoutOption[0]));
                PhysicsVisualizationSettings.SetShowSphereColliders(filterWorkflow, EditorGUILayout.Toggle(GUIContent.Temp(str + "SphereColliders", str + "collision geometry from SphereColliders"), PhysicsVisualizationSettings.GetShowSphereColliders(filterWorkflow), new GUILayoutOption[0]));
                PhysicsVisualizationSettings.SetShowCapsuleColliders(filterWorkflow, EditorGUILayout.Toggle(GUIContent.Temp(str + "CapsuleColliders", str + "collision geometry from CapsuleColliders"), PhysicsVisualizationSettings.GetShowCapsuleColliders(filterWorkflow), new GUILayoutOption[0]));
                PhysicsVisualizationSettings.SetShowMeshColliders(filterWorkflow, PhysicsVisualizationSettings.MeshColliderType.Convex, EditorGUILayout.Toggle(GUIContent.Temp(str + "MeshColliders (convex)", str + "collision geometry from convex MeshColliders"), PhysicsVisualizationSettings.GetShowMeshColliders(filterWorkflow, PhysicsVisualizationSettings.MeshColliderType.Convex), new GUILayoutOption[0]));
                PhysicsVisualizationSettings.SetShowMeshColliders(filterWorkflow, PhysicsVisualizationSettings.MeshColliderType.NonConvex, EditorGUILayout.Toggle(GUIContent.Temp(str + "MeshColliders (concave)", str + "collision geometry from non-convex MeshColliders"), PhysicsVisualizationSettings.GetShowMeshColliders(filterWorkflow, PhysicsVisualizationSettings.MeshColliderType.NonConvex), new GUILayoutOption[0]));
                PhysicsVisualizationSettings.SetShowTerrainColliders(filterWorkflow, EditorGUILayout.Toggle(GUIContent.Temp(str + "TerrainColliders", str + "collision geometry from TerrainColliders"), PhysicsVisualizationSettings.GetShowTerrainColliders(filterWorkflow), new GUILayoutOption[0]));
                EditorGUIUtility.labelWidth = labelWidth;
                EditorGUI.indentLevel--;
            }
            GUILayout.Space(4f);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            bool flag  = GUILayout.Button(str + "None", "MiniButton", new GUILayoutOption[0]);
            bool flag2 = GUILayout.Button(str + "All", "MiniButton", new GUILayoutOption[0]);

            if (flag || flag2)
            {
                PhysicsVisualizationSettings.SetShowForAllFilters(filterWorkflow, flag2);
            }
            GUILayout.EndHorizontal();
            this.m_ColorFoldout = EditorGUILayout.Foldout(this.m_ColorFoldout, "Colors");
            if (this.m_ColorFoldout)
            {
                EditorGUI.indentLevel++;
                PhysicsVisualizationSettings.staticColor       = EditorGUILayout.ColorField(PhysicsDebugWindow.Contents.staticColor, PhysicsVisualizationSettings.staticColor, new GUILayoutOption[0]);
                PhysicsVisualizationSettings.triggerColor      = EditorGUILayout.ColorField(PhysicsDebugWindow.Contents.triggerColor, PhysicsVisualizationSettings.triggerColor, new GUILayoutOption[0]);
                PhysicsVisualizationSettings.rigidbodyColor    = EditorGUILayout.ColorField(PhysicsDebugWindow.Contents.rigidbodyColor, PhysicsVisualizationSettings.rigidbodyColor, new GUILayoutOption[0]);
                PhysicsVisualizationSettings.kinematicColor    = EditorGUILayout.ColorField(PhysicsDebugWindow.Contents.kinematicColor, PhysicsVisualizationSettings.kinematicColor, new GUILayoutOption[0]);
                PhysicsVisualizationSettings.sleepingBodyColor = EditorGUILayout.ColorField(PhysicsDebugWindow.Contents.sleepingBodyColor, PhysicsVisualizationSettings.sleepingBodyColor, new GUILayoutOption[0]);
                PhysicsVisualizationSettings.colorVariance     = EditorGUILayout.Slider("Variation", PhysicsVisualizationSettings.colorVariance, 0f, 1f, new GUILayoutOption[0]);
                EditorGUI.indentLevel--;
            }
            this.m_RenderingFoldout = EditorGUILayout.Foldout(this.m_RenderingFoldout, "Rendering");
            if (this.m_RenderingFoldout)
            {
                EditorGUI.indentLevel++;
                PhysicsVisualizationSettings.baseAlpha       = 1f - EditorGUILayout.Slider("Transparency", 1f - PhysicsVisualizationSettings.baseAlpha, 0f, 1f, new GUILayoutOption[0]);
                PhysicsVisualizationSettings.forceOverdraw   = EditorGUILayout.Toggle(PhysicsDebugWindow.Contents.forceOverdraw, PhysicsVisualizationSettings.forceOverdraw, new GUILayoutOption[0]);
                PhysicsVisualizationSettings.viewDistance    = EditorGUILayout.FloatField(PhysicsDebugWindow.Contents.viewDistance, PhysicsVisualizationSettings.viewDistance, new GUILayoutOption[0]);
                PhysicsVisualizationSettings.terrainTilesMax = EditorGUILayout.IntField(PhysicsDebugWindow.Contents.terrainTilesMax, PhysicsVisualizationSettings.terrainTilesMax, new GUILayoutOption[0]);
                EditorGUI.indentLevel--;
            }
            if (Unsupported.IsDeveloperMode() || PhysicsVisualizationSettings.devOptions)
            {
                PhysicsVisualizationSettings.devOptions = EditorGUILayout.Toggle(PhysicsDebugWindow.Contents.devOptions, PhysicsVisualizationSettings.devOptions, new GUILayoutOption[0]);
            }
            if (PhysicsVisualizationSettings.devOptions)
            {
                PhysicsVisualizationSettings.dotAlpha = EditorGUILayout.Slider("dotAlpha", PhysicsVisualizationSettings.dotAlpha, -1f, 1f, new GUILayoutOption[0]);
                PhysicsVisualizationSettings.forceDot = EditorGUILayout.Toggle(PhysicsDebugWindow.Contents.forceDot, PhysicsVisualizationSettings.forceDot, new GUILayoutOption[0]);
                Tools.hidden = EditorGUILayout.Toggle(PhysicsDebugWindow.Contents.toolsHidden, Tools.hidden, new GUILayoutOption[0]);
            }
            GUILayout.EndScrollView();
            if (dirtyCount != PhysicsVisualizationSettings.dirtyCount)
            {
                PhysicsDebugWindow.RepaintSceneAndGameViews();
            }
        }