Exemple #1
0
        private void DrawReArrangeGUI()
        {
            string label = "Re-Arrange";
            string id    = "rearrange" + instance.GetInstanceID();

            GEditorCommon.Foldout(label, false, id, () =>
            {
                string s = string.Format(
                    "This function requires terrain neighboring to be set and the following properties to be overriden:\n" +
                    "   - Width\n" +
                    "   - Length");
                EditorGUILayout.LabelField(s, GEditorCommon.WordWrapItalicLabel);
                GGeometryOverride g = instance.GeometryOverride;
                GUI.enabled         =
                    g.OverrideWidth &&
                    g.OverrideLength;
                if (GUILayout.Button("Re-Arrange"))
                {
                    GAnalytics.Record(GAnalytics.GROUP_REARRANGE);
                    instance.ReArrange();
                    GUtilities.MarkCurrentSceneDirty();
                }

                GUI.enabled = true;
            });
        }
Exemple #2
0
        private void DrawGeometryOverrideGUI()
        {
            string label = "Geometry Override";
            string id    = "geometryoverride" + instance.GetInstanceID();

            GenericMenu context = new GenericMenu();

            context.AddItem(
                new GUIContent("Default"),
                false,
                () => { instance.ResetGeometry(); });
            context.AddSeparator(null);
            context.AddItem(
                new GUIContent("Reset"),
                false,
                () =>
            {
                if (EditorUtility.DisplayDialog(
                        "Confirm",
                        "Reset geometry data on this terrain group? This action cannot be undone!",
                        "OK", "Cancel"))
                {
                    GCommon.ForEachTerrain(
                        instance.GroupId,
                        (t) =>
                    {
                        if (t.TerrainData == null)
                        {
                            return;
                        }
                        t.TerrainData.Geometry.ResetFull();
                    });
                    GStylizedTerrain.MatchEdges(instance.GroupId);
                }
            });
            context.AddItem(
                new GUIContent("Update"),
                false,
                () =>
            {
                GCommon.ForEachTerrain(
                    instance.GroupId,
                    (t) =>
                {
                    if (t.TerrainData == null)
                    {
                        return;
                    }
                    t.TerrainData.Geometry.SetRegionDirty(GCommon.UnitRect);
                    t.TerrainData.SetDirty(GTerrainData.DirtyFlags.Geometry);
                });
            });
            context.AddItem(
                new GUIContent("Clean Up"),
                false,
                () =>
            {
                GCommon.ForEachTerrain(
                    instance.GroupId,
                    (t) =>
                {
                    if (t.TerrainData == null)
                    {
                        return;
                    }
                    t.TerrainData.Geometry.CleanUp();
                });
            });

            GEditorCommon.Foldout(label, false, id, () =>
            {
                EditorGUILayout.LabelField("Use with cause, this section takes time to process. You may want to use Deferred Update.", GEditorCommon.WordWrapItalicLabel);

                EditorGUI.indentLevel -= 1;
                GGeometryOverride g    = instance.GeometryOverride;
                EditorGUI.BeginChangeCheck();
                float labelWidth            = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = labelWidth - TOGGLE_WIDTH;

                EditorGUI.indentLevel += 1;
                GEditorCommon.Header("Dimension");
                EditorGUI.indentLevel -= 1;

                EditorGUILayout.BeginHorizontal();
                g.OverrideWidth = EditorGUILayout.Toggle(g.OverrideWidth, GUILayout.Width(TOGGLE_WIDTH));
                g.Width         = EditorGUILayout.DelayedFloatField("Width", g.Width);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                g.OverrideHeight = EditorGUILayout.Toggle(g.OverrideHeight, GUILayout.Width(TOGGLE_WIDTH));
                g.Height         = EditorGUILayout.DelayedFloatField("Height", g.Height);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                g.OverrideLength = EditorGUILayout.Toggle(g.OverrideLength, GUILayout.Width(TOGGLE_WIDTH));
                g.Length         = EditorGUILayout.DelayedFloatField("Length", g.Length);
                EditorGUILayout.EndHorizontal();

                EditorGUI.indentLevel += 1;
                GEditorCommon.Header("Height Map");
                EditorGUI.indentLevel -= 1;

                EditorGUILayout.BeginHorizontal();
                g.OverrideHeightMapResolution = EditorGUILayout.Toggle(g.OverrideHeightMapResolution, GUILayout.Width(TOGGLE_WIDTH));
                g.HeightMapResolution         = EditorGUILayout.DelayedIntField("Height Map Resolution", g.HeightMapResolution);
                EditorGUILayout.EndHorizontal();

                EditorGUI.indentLevel += 1;
                GEditorCommon.Header("Mesh Generation");
                EditorGUI.indentLevel -= 1;

                EditorGUILayout.BeginHorizontal();
                g.OverrideMeshBaseResolution = EditorGUILayout.Toggle(g.OverrideMeshBaseResolution, GUILayout.Width(TOGGLE_WIDTH));
                g.MeshBaseResolution         = EditorGUILayout.DelayedIntField("Mesh Base Resolution", g.MeshBaseResolution);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                g.OverrideMeshResolution = EditorGUILayout.Toggle(g.OverrideMeshResolution, GUILayout.Width(TOGGLE_WIDTH));
                g.MeshResolution         = EditorGUILayout.DelayedIntField("Mesh Resolution", g.MeshResolution);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                g.OverrideChunkGridSize = EditorGUILayout.Toggle(g.OverrideChunkGridSize, GUILayout.Width(TOGGLE_WIDTH));
                g.ChunkGridSize         = EditorGUILayout.DelayedIntField("Chunk Grid Size", g.ChunkGridSize);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                g.OverrideLodCount = EditorGUILayout.Toggle(g.OverrideLodCount, GUILayout.Width(TOGGLE_WIDTH));
                g.LODCount         = EditorGUILayout.DelayedIntField("LOD Count", g.LODCount);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                g.OverrideDisplacementSeed = EditorGUILayout.Toggle(g.OverrideDisplacementSeed, GUILayout.Width(TOGGLE_WIDTH));
                g.DisplacementSeed         = EditorGUILayout.DelayedIntField("Displacement Seed", g.DisplacementSeed);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                g.OverrideDisplacementStrength = EditorGUILayout.Toggle(g.OverrideDisplacementStrength, GUILayout.Width(TOGGLE_WIDTH));
                g.DisplacementStrength         = EditorGUILayout.DelayedFloatField("Displacement Strength", g.DisplacementStrength);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                g.OverrideAlbedoToVertexColorMode = EditorGUILayout.Toggle(g.OverrideAlbedoToVertexColorMode, GUILayout.Width(TOGGLE_WIDTH));
                g.AlbedoToVertexColorMode         = (GAlbedoToVertexColorMode)EditorGUILayout.EnumPopup("Albedo To Vertex Color", g.AlbedoToVertexColorMode);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                g.OverrideStorageMode = EditorGUILayout.Toggle(g.OverrideStorageMode, GUILayout.Width(TOGGLE_WIDTH));
                g.StorageMode         = (GGeometry.GStorageMode)EditorGUILayout.EnumPopup("Storage", g.StorageMode);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                g.OverrideAllowTimeSlicedGeneration = EditorGUILayout.Toggle(g.OverrideAllowTimeSlicedGeneration, GUILayout.Width(TOGGLE_WIDTH));
                g.AllowTimeSlicedGeneration         = EditorGUILayout.Toggle("Time Sliced", g.AllowTimeSlicedGeneration);
                EditorGUILayout.EndHorizontal();

                EditorGUIUtility.labelWidth = labelWidth;

                if (EditorGUI.EndChangeCheck())
                {
                    instance.GeometryOverride = g;
                    if (!instance.DeferredUpdate)
                    {
                        GAnalytics.Record(GAnalytics.GROUP_OVERRIDE_GEOMETRY);
                        EditorUtility.DisplayProgressBar("Overriding", "Re-generating terrains geometry", 1);
                        instance.OverrideGeometry();
                        EditorUtility.ClearProgressBar();
                    }
                }
                EditorGUI.indentLevel += 1;
            }, context);
        }