private void DoBulkExport()
        {
            GCommon.ForEachTerrain(
                BulkExportGroupId,
                (t) =>
            {
                if (t == null || t.TerrainData == null)
                {
                    return;
                }

                GUnityTerrainDataExporter exporter = new GUnityTerrainDataExporter();
                exporter.SrcData              = t.TerrainData;
                exporter.DesData              = null;
                exporter.CreateNewAsset       = true;
                exporter.ExportGeometry       = ExportGeometry;
                exporter.ExportTerrainSize    = ExportTerrainSize;
                exporter.ExportSplats         = ExportSplats;
                exporter.OverwriteSplatLayers = false;
                exporter.ExportTrees          = ExportTrees;
                exporter.ExportGrasses        = ExportGrasses;
                exporter.DataDirectory        = DataDirectory;

                exporter.Export();
            });
        }
 private void DrawMask(Camera cam)
 {
     GCommon.ForEachTerrain(instance.GroupId, (t) =>
     {
         GLivePreviewDrawer.DrawTerrainMask(t, cam);
     });
 }
 public static void SetShader(int groupId)
 {
     GEditorSettings.WizardToolsSettings settings = GEditorSettings.Instance.wizardTools;
     GCommon.ForEachTerrain(groupId, (t) =>
     {
         SetShader(t, settings.lightingModel, settings.texturingModel, settings.splatsModel);
     });
 }
Пример #4
0
        public static List <GStylizedTerrain> CheckOverlap(int groupId, Rect stamperRect)
        {
            List <GStylizedTerrain> terrains = new List <GStylizedTerrain>();

            GCommon.ForEachTerrain(groupId, (t) =>
            {
                if (stamperRect.Overlaps(t.Rect))
                {
                    terrains.Add(t);
                }
            });
            return(terrains);
        }
        private void DoBulkImport()
        {
            string[]         guid     = AssetDatabase.FindAssets("t:Texture2D", new string[] { Directory });
            List <Texture2D> textures = new List <Texture2D>();

            for (int i = 0; i < guid.Length; ++i)
            {
                string    path = AssetDatabase.GUIDToAssetPath(guid[i]);
                Texture2D tex  = AssetDatabase.LoadAssetAtPath <Texture2D>(path);
                textures.Add(tex);
            }

            GCommon.ForEachTerrain(
                BulkImportGroupId,
                (t) =>
            {
                if (t == null || t.TerrainData == null)
                {
                    return;
                }

                GBackup.TryCreateInitialBackup(HISTORY_PREFIX, t, GCommon.AllResourceFlags);

                Texture2D hm   = textures.Find(tex => tex.name.StartsWith("HeightMap") && tex.name.EndsWith(t.TerrainData.Id));
                Texture2D mkm  = textures.Find(tex => tex.name.StartsWith("MaskMap") && tex.name.EndsWith(t.TerrainData.Id));
                Texture2D vm   = textures.Find(tex => tex.name.StartsWith("VisibilityMap") && tex.name.EndsWith(t.TerrainData.Id));
                Texture2D am   = textures.Find(tex => tex.name.StartsWith("AlbedoMap") && tex.name.EndsWith(t.TerrainData.Id));
                Texture2D mm   = textures.Find(tex => tex.name.StartsWith("MetallicMap") && tex.name.EndsWith(t.TerrainData.Id));
                Texture2D[] cm = new Texture2D[t.TerrainData.Shading.SplatControlMapCount];
                for (int i = 0; i < cm.Length; ++i)
                {
                    cm[i] = textures.Find(tex => tex.name.StartsWith("ControlMap" + i.ToString()) && tex.name.EndsWith(t.TerrainData.Id));
                }

                GTextureImporter importer = new GTextureImporter();
                importer.Terrain          = t;
                importer.DesData          = t.TerrainData;
                importer.HeightMap        = hm;
                importer.MaskMap          = mkm;
                importer.VisibilityMap    = vm;
                importer.AlbedoMap        = am;
                importer.MetallicMap      = mm;
                importer.SplatControlMaps = cm;
                importer.Import();

                GBackup.TryCreateBackup(HISTORY_PREFIX, t, GCommon.AllResourceFlags);
            });

            GStylizedTerrain.MatchEdges(BulkImportGroupId);
        }
Пример #6
0
        public static List <GStylizedTerrain> OverlapTest(int groupId, GSplineCreator spline)
        {
            List <GStylizedTerrain> terrains = new List <GStylizedTerrain>();

            GCommon.ForEachTerrain(groupId, (t) =>
            {
                if (spline.OverlapTest(t))
                {
                    terrains.Add(t);
                }
            });

            return(terrains);
        }
Пример #7
0
        public static List <GStylizedTerrain> CheckBrushOverlap(
            int groupId,
            Vector3[] worldPointCorners)
        {
            List <GStylizedTerrain> results = new List <GStylizedTerrain>();

            GCommon.ForEachTerrain(groupId, (t) =>
            {
                Rect dirtyRect = GUtilities.GetRectContainsPoints(worldPointCorners);
                if (dirtyRect.Overlaps(t.Rect))
                {
                    results.Add(t);
                }
            });

            return(results);
        }
Пример #8
0
 private void DoBulkExport()
 {
     GCommon.ForEachTerrain(
         BulkExportGroupId,
         (t) =>
     {
         if (t.TerrainData == null)
         {
             return;
         }
         GRawExporter exporter  = new GRawExporter();
         exporter.SrcData       = t.TerrainData;
         exporter.BitDepth      = BitDepth;
         exporter.DataDirectory = DataDirectory;
         exporter.Export();
     });
 }
 private void DrawMask(Camera cam)
 {
     GCommon.ForEachTerrain(painter.GroupId, (t) =>
     {
         if (t.TerrainData == null)
         {
             return;
         }
         if (painter.ActivePainter is GMaskPainter)
         {
             GLivePreviewDrawer.DrawMask4ChannelsLivePreview(t, cam, t.TerrainData.Mask.MaskMap, GCommon.UnitRect);
         }
         else
         {
             GLivePreviewDrawer.DrawTerrainMask(t, cam);
         }
     });
 }
Пример #10
0
        private void DoBulkImport()
        {
            string        ext   = BitDepth == GBitDepth.Bit8 ? "raw" : "r16";
            List <string> files = new List <string>(Directory.GetFiles(DataDirectory));

            files.RemoveAll(f => !f.EndsWith(ext));

            GCommon.ForEachTerrain(
                BulkImportGroupId,
                (t) =>
            {
                if (t == null || t.TerrainData == null)
                {
                    return;
                }

                string file = files.Find(
                    s =>
                {
                    string f = Path.GetFileNameWithoutExtension(s);
                    return(f.StartsWith(BitDepth == GBitDepth.Bit8 ? "RAW8" : "RAW16") && f.EndsWith(t.TerrainData.Id));
                });
                if (string.IsNullOrEmpty(file))
                {
                    return;
                }

                GBackup.TryCreateInitialBackup(HISTORY_PREFIX, t, GCommon.HeightMapAndFoliageResourceFlags);

                GRawImporter importer     = new GRawImporter();
                importer.Terrain          = t;
                importer.DesData          = t.TerrainData;
                importer.BitDepth         = BitDepth;
                importer.UseRawResolution = UseRawResolution;
                importer.FilePath         = file;
                importer.Import();

                GBackup.TryCreateBackup(HISTORY_PREFIX, t, GCommon.HeightMapAndFoliageResourceFlags);
            });
            GStylizedTerrain.MatchEdges(BulkImportGroupId);
        }
Пример #11
0
        private void DoBulkExport()
        {
            GCommon.ForEachTerrain(
                BulkExportGroupId,
                (t) =>
            {
                if (t == null || t.TerrainData == null)
                {
                    return;
                }

                GTextureExporter exporter         = new GTextureExporter();
                exporter.SrcData                  = t.TerrainData;
                exporter.ExportHeightMap          = ExportHeightMap;
                exporter.ExportVisibilityMap      = ExportVisibilityMap;
                exporter.ExportAlbedoMap          = ExportAlbedoMap;
                exporter.ExportMetallicMap        = ExportMetallicMap;
                exporter.ExportGradientLookupMaps = ExportGradientLookupMaps;
                exporter.ExportSplatControlMaps   = ExportSplatControlMaps;
                exporter.DataDirectory            = DataDirectory;

                exporter.Export();
            });
        }
        private void DoBulkImport()
        {
            string[]           guid         = AssetDatabase.FindAssets("t:TerrainData", new string[] { Directory });
            List <TerrainData> terrainDatas = new List <TerrainData>();

            for (int i = 0; i < guid.Length; ++i)
            {
                string      path = AssetDatabase.GUIDToAssetPath(guid[i]);
                TerrainData data = AssetDatabase.LoadAssetAtPath <TerrainData>(path);
                terrainDatas.Add(data);
            }

            GCommon.ForEachTerrain(
                BulkImportGroupId,
                (t) =>
            {
                if (t == null || t.TerrainData == null)
                {
                    return;
                }
                TerrainData srcData = terrainDatas.Find(d => d.name.StartsWith("TerrainData") && d.name.EndsWith(t.TerrainData.Id));
                if (srcData == null)
                {
                    return;
                }

                GBackup.TryCreateInitialBackup(HISTORY_PREFIX, t, GCommon.AllResourceFlags);

                GUnityTerrainDataImporter importer = new GUnityTerrainDataImporter();
                importer.SrcTerrain          = null;
                importer.SrcData             = srcData;
                importer.DesData             = t.TerrainData;
                importer.DesTerrain          = t;
                importer.ImportGeometry      = ImportGeometry;
                importer.UseUnityTerrainSize = UseUnityTerrainSize;

                importer.ImportSplats         = ImportSplats;
                importer.ImportSplatsAsAlbedo = ImportSplatsAsAlbedo;
                bool createNewSplatGroup      = CreateNewSplatPrototypesGroup;
                if (t.TerrainData.Shading.Splats == null ||
                    t.TerrainData.Shading.Splats == GGriffinSettings.Instance.TerrainDataDefault.Shading.Splats)
                {
                    createNewSplatGroup = true;
                }
                importer.CreateNewSplatPrototypesGroup = createNewSplatGroup;

                importer.ImportTrees    = ImportTrees;
                bool createNewTreeGroup = CreateNewTreePrototypesGroup;
                if (t.TerrainData.Foliage.Trees == null ||
                    t.TerrainData.Foliage.Trees == GGriffinSettings.Instance.TerrainDataDefault.Foliage.Trees)
                {
                    createNewTreeGroup = true;
                }
                importer.CreateNewTreePrototypesGroup = createNewTreeGroup;

                importer.ImportGrasses   = ImportGrasses;
                bool createNewGrassGroup = CreateNewGrassPrototypesGroup;
                if (t.TerrainData.Foliage.Grasses == null ||
                    t.TerrainData.Foliage.Grasses == GGriffinSettings.Instance.TerrainDataDefault.Foliage.Grasses)
                {
                    createNewGrassGroup = true;
                }
                importer.CreateNewGrassPrototypesGroup = createNewGrassGroup;

                GrassDensity          = GUnityTerrainDataImporter.GetAdjustedGrassDensity(srcData);
                importer.GrassDensity = GrassDensity;
                importer.Import();

                GBackup.TryCreateBackup(HISTORY_PREFIX, t, GCommon.AllResourceFlags);
            });

            GStylizedTerrain.MatchEdges(BulkImportGroupId);
        }
Пример #13
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);
        }
Пример #14
0
        private void DrawFoliageOverrideGUI()
        {
            string label = "Foliage Override";
            string id    = "foliageoverride" + instance.GetInstanceID();

            GenericMenu context = new GenericMenu();

            context.AddItem(
                new GUIContent("Default"),
                false,
                () =>
            {
                instance.ResetFoliage();
            });
            context.AddSeparator(null);
            context.AddItem(
                new GUIContent("Reset"),
                false,
                () =>
            {
                if (EditorUtility.DisplayDialog(
                        "Confirm",
                        "Reset foliage data on this terrain group? This action cannot be undone!",
                        "OK", "Cancel"))
                {
                    GCommon.ForEachTerrain(
                        instance.GroupId,
                        (t) =>
                    {
                        if (t.TerrainData == null)
                        {
                            return;
                        }
                        t.TerrainData.Foliage.ResetFull();
                    });
                }
            });
            context.AddItem(
                new GUIContent("Refresh"),
                false,
                () =>
            {
                GCommon.ForEachTerrain(
                    instance.GroupId,
                    (t) =>
                {
                    if (t.TerrainData == null)
                    {
                        return;
                    }
                    t.TerrainData.Foliage.Refresh();
                });
            });
            context.AddItem(
                new GUIContent("Clear All Trees"),
                false,
                () =>
            {
                if (EditorUtility.DisplayDialog(
                        "Confirm",
                        "Clear all trees on this terrain group? This action cannot be undone!",
                        "OK", "Cancel"))
                {
                    GCommon.ForEachTerrain(
                        instance.GroupId,
                        (t) =>
                    {
                        if (t.TerrainData == null)
                        {
                            return;
                        }
                        t.TerrainData.Foliage.TreeInstances.Clear();
                    });
                }
            });
            context.AddItem(
                new GUIContent("Clear All Grass"),
                false,
                () =>
            {
                if (EditorUtility.DisplayDialog(
                        "Confirm",
                        "Clear all grasses on this terrain group? This action cannot be undone!",
                        "OK", "Cancel"))
                {
                    GCommon.ForEachTerrain(
                        instance.GroupId,
                        (t) =>
                    {
                        if (t.TerrainData == null)
                        {
                            return;
                        }
                        t.TerrainData.Foliage.ClearGrassInstances();
                    });
                }
            });
            context.AddSeparator(null);
            context.AddItem(
                new GUIContent("Update Trees"),
                false,
                () =>
            {
                GCommon.ForEachTerrain(
                    instance.GroupId,
                    (t) =>
                {
                    if (t.TerrainData == null)
                    {
                        return;
                    }
                    t.TerrainData.Foliage.SetTreeRegionDirty(new Rect(0, 0, 1, 1));
                    t.UpdateTreesPosition(true);
                    t.TerrainData.Foliage.ClearTreeDirtyRegions();
                    t.TerrainData.SetDirty(GTerrainData.DirtyFlags.Foliage);
                });
            });
            context.AddItem(
                new GUIContent("Update Grasses"),
                false,
                () =>
            {
                GCommon.ForEachTerrain(
                    instance.GroupId,
                    (t) =>
                {
                    if (t.TerrainData == null)
                    {
                        return;
                    }
                    t.TerrainData.Foliage.SetGrassRegionDirty(new Rect(0, 0, 1, 1));
                    t.UpdateGrassPatches(-1, true);
                    t.TerrainData.Foliage.ClearGrassDirtyRegions();
                    t.TerrainData.SetDirty(GTerrainData.DirtyFlags.Foliage);
                });
            });

            GEditorCommon.Foldout(label, false, id, () =>
            {
                EditorGUI.indentLevel -= 1;
                GFoliageOverride f     = instance.FoliageOverride;
                EditorGUI.BeginChangeCheck();
                float labelWidth            = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = labelWidth - TOGGLE_WIDTH;

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

                EditorGUILayout.BeginHorizontal();
                f.OverrideTrees = EditorGUILayout.Toggle(f.OverrideTrees, GUILayout.Width(TOGGLE_WIDTH));
                f.Trees         = EditorGUILayout.ObjectField("Prototypes", f.Trees, typeof(GTreePrototypeGroup), false) as GTreePrototypeGroup;
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                f.OverrideTreeSnapMode = EditorGUILayout.Toggle(f.OverrideTreeSnapMode, GUILayout.Width(TOGGLE_WIDTH));
                f.TreeSnapMode         = (GSnapMode)EditorGUILayout.EnumPopup("Tree Snap Mode", f.TreeSnapMode);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                f.OverrideTreeSnapLayerMask = EditorGUILayout.Toggle(f.OverrideTreeSnapLayerMask, GUILayout.Width(TOGGLE_WIDTH));
                f.TreeSnapLayerMask         = EditorGUILayout.LayerField("Tree Snap Layers", f.TreeSnapLayerMask);
                EditorGUILayout.EndHorizontal();

                EditorGUI.indentLevel += 1;
                GEditorCommon.Header("Grasses & Details");
                EditorGUI.indentLevel -= 1;

                EditorGUILayout.BeginHorizontal();
                f.OverrideGrasses = EditorGUILayout.Toggle(f.OverrideGrasses, GUILayout.Width(TOGGLE_WIDTH));
                f.Grasses         = EditorGUILayout.ObjectField("Prototypes", f.Grasses, typeof(GGrassPrototypeGroup), false) as GGrassPrototypeGroup;
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                f.OverrideGrassSnapMode = EditorGUILayout.Toggle(f.OverrideGrassSnapMode, GUILayout.Width(TOGGLE_WIDTH));
                f.GrassSnapMode         = (GSnapMode)EditorGUILayout.EnumPopup("Grass Snap Mode", f.GrassSnapMode);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                f.OverrideGrassSnapLayerMask = EditorGUILayout.Toggle(f.OverrideGrassSnapLayerMask, GUILayout.Width(TOGGLE_WIDTH));
                f.GrassSnapLayerMask         = EditorGUILayout.LayerField("Grass Snap Layers", f.GrassSnapLayerMask);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                f.OverridePatchGridSize = EditorGUILayout.Toggle(f.OverridePatchGridSize, GUILayout.Width(TOGGLE_WIDTH));
                f.PatchGridSize         = EditorGUILayout.DelayedIntField("Patch Grid Size", f.PatchGridSize);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                f.OverrideEnableInteractiveGrass = EditorGUILayout.Toggle(f.OverrideEnableInteractiveGrass, GUILayout.Width(TOGGLE_WIDTH));
                f.EnableInteractiveGrass         = EditorGUILayout.Toggle("Interactive Grass", f.EnableInteractiveGrass);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                f.OverrideVectorFieldMapResolution = EditorGUILayout.Toggle(f.OverrideVectorFieldMapResolution, GUILayout.Width(TOGGLE_WIDTH));
                f.VectorFieldMapResolution         = EditorGUILayout.DelayedIntField("Vector Field Map Resolution", f.VectorFieldMapResolution);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                f.OverrideBendSensitive = EditorGUILayout.Toggle(f.OverrideBendSensitive, GUILayout.Width(TOGGLE_WIDTH));
                f.BendSensitive         = EditorGUILayout.DelayedFloatField("Bend Sensitive", f.BendSensitive);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                f.OverrideRestoreSensitive = EditorGUILayout.Toggle(f.OverrideRestoreSensitive, GUILayout.Width(TOGGLE_WIDTH));
                f.RestoreSensitive         = EditorGUILayout.DelayedFloatField("Restore Sensitive", f.RestoreSensitive);
                EditorGUILayout.EndHorizontal();

                EditorGUIUtility.labelWidth = labelWidth;

                if (EditorGUI.EndChangeCheck())
                {
                    instance.FoliageOverride = f;
                    if (!instance.DeferredUpdate)
                    {
                        GAnalytics.Record(GAnalytics.GROUP_OVERRIDE_FOLIAGE);
                        instance.OverrideFoliage();
                    }
                }
                EditorGUI.indentLevel += 1;
            }, context);
        }
Пример #15
0
        private void DrawRenderingOverrideGUI()
        {
            string label = "Rendering Override";
            string id    = "renderingoverride" + instance.GetInstanceID();

            GenericMenu context = new GenericMenu();

            context.AddItem(
                new GUIContent("Default"),
                false,
                () =>
            {
                instance.ResetRendering();
            });
            context.AddSeparator(null);
            context.AddItem(
                new GUIContent("Reset"),
                false,
                () =>
            {
                GCommon.ForEachTerrain(
                    instance.GroupId,
                    (t) =>
                {
                    if (t.TerrainData == null)
                    {
                        return;
                    }
                    t.TerrainData.Rendering.ResetFull();
                });
            });


            GEditorCommon.Foldout(label, false, id, () =>
            {
                EditorGUI.indentLevel -= 1;
                GRenderingOverride r   = instance.RenderingOverride;
                EditorGUI.BeginChangeCheck();
                float labelWidth            = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = labelWidth - TOGGLE_WIDTH;

                EditorGUI.indentLevel += 1;
                GEditorCommon.Header("Terrain Shadow");
                EditorGUI.indentLevel -= 1;
                EditorGUILayout.BeginHorizontal();
                r.OverrideCastShadow = EditorGUILayout.Toggle(r.OverrideCastShadow, GUILayout.Width(TOGGLE_WIDTH));
                r.CastShadow         = EditorGUILayout.Toggle("Cast Shadow", r.CastShadow);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                r.OverrideReceiveShadow = EditorGUILayout.Toggle(r.OverrideReceiveShadow, GUILayout.Width(TOGGLE_WIDTH));
                r.ReceiveShadow         = EditorGUILayout.Toggle("Receive Shadow", r.ReceiveShadow);
                EditorGUILayout.EndHorizontal();

                EditorGUI.indentLevel += 1;
                GEditorCommon.Header("Tree Rendering");
                EditorGUI.indentLevel -= 1;
                EditorGUILayout.BeginHorizontal();
                r.OverrideDrawTrees = EditorGUILayout.Toggle(r.OverrideDrawTrees, GUILayout.Width(TOGGLE_WIDTH));
                r.DrawTrees         = EditorGUILayout.Toggle("Draw", r.DrawTrees);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                r.OverrideEnableInstancing = EditorGUILayout.Toggle(r.OverrideEnableInstancing, GUILayout.Width(TOGGLE_WIDTH));
                r.EnableInstancing         = EditorGUILayout.Toggle("Enable Instancing", r.EnableInstancing);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                r.OverrideBillboardStart = EditorGUILayout.Toggle(r.OverrideBillboardStart, GUILayout.Width(TOGGLE_WIDTH));
                r.BillboardStart         = EditorGUILayout.Slider("Billboard Start", r.BillboardStart, 0f, GCommon.MAX_TREE_DISTANCE);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                r.OverrideTreeDistance = EditorGUILayout.Toggle(r.OverrideTreeDistance, GUILayout.Width(TOGGLE_WIDTH));
                r.TreeDistance         = EditorGUILayout.Slider("Tree Distance", r.TreeDistance, 0f, GCommon.MAX_TREE_DISTANCE);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                GUI.enabled = false;
                EditorGUILayout.Toggle(true, GUILayout.Width(TOGGLE_WIDTH));
                GUI.enabled = true;
                GRuntimeSettings.Instance.renderingDefault.cullVolumeBias = EditorGUILayout.Slider("Cull Volume Bias", GRuntimeSettings.Instance.renderingDefault.cullVolumeBias, 0f, 100f);
                EditorGUILayout.EndHorizontal();

                EditorGUI.indentLevel += 1;
                GEditorCommon.Header("Grass & Detail Rendering");
                EditorGUI.indentLevel -= 1;
                EditorGUILayout.BeginHorizontal();
                r.OverrideDrawGrasses = EditorGUILayout.Toggle(r.OverrideDrawGrasses, GUILayout.Width(TOGGLE_WIDTH));
                r.DrawGrasses         = EditorGUILayout.Toggle("Draw", r.DrawGrasses);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                r.OverrideGrassDistance = EditorGUILayout.Toggle(r.OverrideGrassDistance, GUILayout.Width(TOGGLE_WIDTH));
                r.GrassDistance         = EditorGUILayout.Slider("Grass Distance", r.GrassDistance, 0f, GCommon.MAX_GRASS_DISTANCE);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                r.OverrideGrassFadeStart = EditorGUILayout.Toggle(r.OverrideGrassFadeStart, GUILayout.Width(TOGGLE_WIDTH));
                r.GrassFadeStart         = EditorGUILayout.Slider("Fade Start", r.GrassFadeStart, 0f, 1f);
                EditorGUILayout.EndHorizontal();

                EditorGUIUtility.labelWidth = labelWidth;

                if (EditorGUI.EndChangeCheck())
                {
                    instance.RenderingOverride = r;
                    if (!instance.DeferredUpdate)
                    {
                        GAnalytics.Record(GAnalytics.GROUP_OVERRIDE_RENDERING);
                        instance.OverrideRendering();
                    }
                }
                EditorGUI.indentLevel += 1;
            }, context);
        }
Пример #16
0
        private void DrawShadingOverrideGUI()
        {
            string label = "Shading Override";
            string id    = "shadingoverride" + instance.GetInstanceID();

            GenericMenu context = new GenericMenu();

            context.AddItem(
                new GUIContent("Default"),
                false,
                () =>
            {
                instance.ResetShading();
            });
            context.AddSeparator(null);
            context.AddItem(
                new GUIContent("Reset"),
                false,
                () =>
            {
                GCommon.ForEachTerrain(
                    instance.GroupId,
                    (t) =>
                {
                    if (t.TerrainData == null)
                    {
                        return;
                    }
                    t.TerrainData.Shading.ResetFull();
                });
            });
            context.AddItem(
                new GUIContent("Refresh"),
                false,
                () =>
            {
                GCommon.ForEachTerrain(
                    instance.GroupId,
                    (t) =>
                {
                    if (t.TerrainData == null)
                    {
                        return;
                    }
                    t.TerrainData.Shading.UpdateLookupTextures();
                    t.TerrainData.Shading.UpdateMaterials();
                });
            });
            context.AddItem(
                new GUIContent("Set Shader"),
                false,
                () =>
            {
                GWizardWindow.ShowSetShaderTab(instance.GroupId);
            });


            GEditorCommon.Foldout(label, false, id, () =>
            {
                EditorGUI.indentLevel -= 1;
                GShadingOverride s     = instance.ShadingOverride;
                EditorGUI.BeginChangeCheck();
                float labelWidth            = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = labelWidth - TOGGLE_WIDTH;

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

                EditorGUILayout.BeginHorizontal();
                s.OverrideCustomMaterial = EditorGUILayout.Toggle(s.OverrideCustomMaterial, GUILayout.Width(TOGGLE_WIDTH));
                s.CustomMaterial         = EditorGUILayout.ObjectField("Material Template", s.CustomMaterial, typeof(Material), false) as Material;
                EditorGUILayout.EndHorizontal();

                EditorGUI.indentLevel += 1;
                GEditorCommon.Header("Color Map & Gradient Lookup");
                EditorGUI.indentLevel -= 1;

                EditorGUILayout.BeginHorizontal();
                s.OverrideAlbedoMapResolution = EditorGUILayout.Toggle(s.OverrideAlbedoMapResolution, GUILayout.Width(TOGGLE_WIDTH));
                s.AlbedoMapResolution         = EditorGUILayout.DelayedIntField("Albedo Map Resolution", s.AlbedoMapResolution);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideMetallicMapResolution = EditorGUILayout.Toggle(s.OverrideMetallicMapResolution, GUILayout.Width(TOGGLE_WIDTH));
                s.MetallicMapResolution         = EditorGUILayout.DelayedIntField("Metallic Map Resolution", s.MetallicMapResolution);
                EditorGUILayout.EndHorizontal();

                SerializedObject so   = new SerializedObject(instance);
                SerializedProperty sp = so.FindProperty("shadingOverride");

                EditorGUILayout.BeginHorizontal();
                s.OverrideColorByNormal     = EditorGUILayout.Toggle(s.OverrideColorByNormal, GUILayout.Width(TOGGLE_WIDTH));
                SerializedProperty cbnProps = sp.FindPropertyRelative("colorByNormal");
                EditorGUILayout.PropertyField(cbnProps);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideColorBlendCurve = EditorGUILayout.Toggle(s.OverrideColorBlendCurve, GUILayout.Width(TOGGLE_WIDTH));
                s.ColorBlendCurve         = EditorGUILayout.CurveField("Blend By Height", s.ColorBlendCurve, Color.red, new Rect(0, 0, 1, 1));
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideColorByHeight     = EditorGUILayout.Toggle(s.OverrideColorByHeight, GUILayout.Width(TOGGLE_WIDTH));
                SerializedProperty cbhProps = sp.FindPropertyRelative("colorByHeight");
                EditorGUILayout.PropertyField(cbhProps);
                EditorGUILayout.EndHorizontal();

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

                EditorGUILayout.BeginHorizontal();
                s.OverrideSplats = EditorGUILayout.Toggle(s.OverrideSplats, GUILayout.Width(TOGGLE_WIDTH));
                s.Splats         = EditorGUILayout.ObjectField("Prototypes", s.Splats, typeof(GSplatPrototypeGroup), false) as GSplatPrototypeGroup;
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideSplatControlResolution = EditorGUILayout.Toggle(s.OverrideSplatControlResolution, GUILayout.Width(TOGGLE_WIDTH));
                s.SplatControlResolution         = EditorGUILayout.DelayedIntField("Splat Control Maps Resolution", s.SplatControlResolution);
                EditorGUILayout.EndHorizontal();

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

                EditorGUILayout.BeginHorizontal();
                s.OverrideAlbedoMapPropertyName = EditorGUILayout.Toggle(s.OverrideAlbedoMapPropertyName, GUILayout.Width(TOGGLE_WIDTH));
                s.AlbedoMapPropertyName         = EditorGUILayout.DelayedTextField("Albedo Map Property Name", s.AlbedoMapPropertyName);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideMetallicMapPropertyName = EditorGUILayout.Toggle(s.OverrideMetallicMapPropertyName, GUILayout.Width(TOGGLE_WIDTH));
                s.MetallicMapPropertyName         = EditorGUILayout.DelayedTextField("Metallic Map Property Name", s.MetallicMapPropertyName);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideColorByHeightPropertyName = EditorGUILayout.Toggle(s.OverrideColorByHeightPropertyName, GUILayout.Width(TOGGLE_WIDTH));
                s.ColorByHeightPropertyName         = EditorGUILayout.DelayedTextField("Color By Height Property Name", s.ColorByHeightPropertyName);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideColorByNormalPropertyName = EditorGUILayout.Toggle(s.OverrideColorByNormalPropertyName, GUILayout.Width(TOGGLE_WIDTH));
                s.ColorByNormalPropertyName         = EditorGUILayout.DelayedTextField("Color By Normal Property Name", s.ColorByNormalPropertyName);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideColorBlendPropertyName = EditorGUILayout.Toggle(s.OverrideColorBlendPropertyName, GUILayout.Width(TOGGLE_WIDTH));
                s.ColorBlendPropertyName         = EditorGUILayout.DelayedTextField("Color Blend Property Name", s.ColorBlendPropertyName);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideDimensionPropertyName = EditorGUILayout.Toggle(s.OverrideDimensionPropertyName, GUILayout.Width(TOGGLE_WIDTH));
                s.DimensionPropertyName         = EditorGUILayout.DelayedTextField("Dimension Property Name", s.DimensionPropertyName);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideSplatControlMapPropertyName = EditorGUILayout.Toggle(s.OverrideSplatControlMapPropertyName, GUILayout.Width(TOGGLE_WIDTH));
                s.SplatControlMapPropertyName         = EditorGUILayout.DelayedTextField("Splat Control Map Property Name", s.SplatControlMapPropertyName);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideSplatMapPropertyName = EditorGUILayout.Toggle(s.OverrideSplatMapPropertyName, GUILayout.Width(TOGGLE_WIDTH));
                s.SplatMapPropertyName         = EditorGUILayout.DelayedTextField("Splat Map Property Name", s.SplatMapPropertyName);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideSplatNormalPropertyName = EditorGUILayout.Toggle(s.OverrideSplatNormalPropertyName, GUILayout.Width(TOGGLE_WIDTH));
                s.SplatNormalPropertyName         = EditorGUILayout.DelayedTextField("Splat Normal Property Name", s.SplatNormalPropertyName);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideSplatMetallicPropertyName = EditorGUILayout.Toggle(s.OverrideSplatMetallicPropertyName, GUILayout.Width(TOGGLE_WIDTH));
                s.SplatMetallicPropertyName         = EditorGUILayout.DelayedTextField("Splat Metallic Property Name", s.SplatMetallicPropertyName);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                s.OverrideSplatSmoothnessPropertyName = EditorGUILayout.Toggle(s.OverrideSplatSmoothnessPropertyName, GUILayout.Width(TOGGLE_WIDTH));
                s.SplatSmoothnessPropertyName         = EditorGUILayout.DelayedTextField("Splat Smoothness Property Name", s.SplatSmoothnessPropertyName);
                EditorGUILayout.EndHorizontal();

                EditorGUIUtility.labelWidth = labelWidth;

                if (EditorGUI.EndChangeCheck())
                {
                    so.ApplyModifiedProperties();
                    instance.ShadingOverride = s;
                    if (!instance.DeferredUpdate)
                    {
                        GAnalytics.Record(GAnalytics.GROUP_OVERRIDE_SHADING);
                        instance.OverrideShading();
                    }
                }
                so.Dispose();
                sp.Dispose();
                cbhProps.Dispose();
                cbnProps.Dispose();
                EditorGUI.indentLevel += 1;
            }, context);
        }