Пример #1
0
        private void OnEnable()
        {
            instance = (GStylizedTerrain)target;
            if (instance.TerrainData != null)
            {
                instance.TerrainData.Shading.UpdateMaterials();
            }

            geometryAdditionalContextAction = new List <GGenericMenuItem>();
            geometryAdditionalContextAction.Add(new GGenericMenuItem(
                                                    "Add Height Map Filter",
                                                    false,
                                                    () =>
            {
                GHeightMapFilter filterComponent = instance.GetComponent <GHeightMapFilter>();
                if (filterComponent == null)
                {
                    instance.gameObject.AddComponent <GHeightMapFilter>();
                }
            }));

            foliageAdditionalContextAction = new List <GGenericMenuItem>();
            foliageAdditionalContextAction.Add(new GGenericMenuItem(
                                                   "Update Trees",
                                                   false,
                                                   () =>
            {
                if (instance.TerrainData != null)
                {
                    instance.TerrainData.Foliage.SetTreeRegionDirty(new Rect(0, 0, 1, 1));
                    instance.UpdateTreesPosition(true);
                    instance.TerrainData.Foliage.ClearTreeDirtyRegions();
                    instance.TerrainData.SetDirty(GTerrainData.DirtyFlags.Foliage);
                }
            }));
            foliageAdditionalContextAction.Add(new GGenericMenuItem(
                                                   "Update Grasses",
                                                   false,
                                                   () =>
            {
                if (instance.TerrainData != null)
                {
                    instance.TerrainData.Foliage.SetGrassRegionDirty(new Rect(0, 0, 1, 1));
                    instance.UpdateGrassPatches(-1, true);
                    instance.TerrainData.Foliage.ClearGrassDirtyRegions();
                    instance.TerrainData.SetDirty(GTerrainData.DirtyFlags.Foliage);
                }
            }));
        }