public void CopyTo(GFoliage des)
 {
     des.Trees              = Trees;
     des.TreeSnapMode       = TreeSnapMode;
     des.TreeSnapLayerMask  = TreeSnapLayerMask;
     des.Grasses            = Grasses;
     des.GrassSnapMode      = GrassSnapMode;
     des.GrassSnapLayerMask = GrassSnapLayerMask;
     des.PatchGridSize      = PatchGridSize;
 }
Example #2
0
        private void DrawFoliageGUI()
        {
            string label = "Foliage";
            string id    = "foliage" + data.Id;

            GenericMenu menu = new GenericMenu();

            menu.AddItem(
                new GUIContent("Reset"),
                false,
                () => { ConfirmAndResetFoliage(); });
            menu.AddItem(
                new GUIContent("Refresh"),
                false,
                () => { data.Foliage.Refresh(); });
            menu.AddItem(
                new GUIContent("Clear All Trees"),
                false,
                () => { ConfirmAndClearAllTrees(); });
            menu.AddItem(
                new GUIContent("Clear All Grasses"),
                false,
                () => { ConfirmAndClearAllGrasses(); });

            if (foliageAdditionalContextAction != null && foliageAdditionalContextAction.Count > 0)
            {
                menu.AddSeparator(null);
                for (int i = 0; i < foliageAdditionalContextAction.Count; ++i)
                {
                    menu.AddItem(
                        new GUIContent(foliageAdditionalContextAction[i].Name),
                        foliageAdditionalContextAction[i].IsOn,
                        foliageAdditionalContextAction[i].Action);
                }
            }

            GFoliage settings           = data.Foliage;
            bool     showUpgradeMessage = settings.grassVersion < GFoliage.GRASS_VERSION_COMPRESSED;

            if (showUpgradeMessage)
            {
                menu.AddSeparator(null);
                menu.AddItem(
                    new GUIContent("Upgrade Grass Serialize Version"),
                    false,
                    () =>
                {
                    settings.Internal_UpgradeGrassSerializeVersion();
                });
            }

            string headerWarning = null;

            if (showUpgradeMessage)
            {
                headerWarning = "New grass serialize version is available, use context menu to upgrade (Recommended).";
            }

            GEditorCommon.Foldout(label, false, id, () =>
            {
                EditorGUI.BeginChangeCheck();
                GEditorCommon.Header("Trees");
                settings.Trees        = EditorGUILayout.ObjectField("Prototypes", settings.Trees, typeof(GTreePrototypeGroup), false) as GTreePrototypeGroup;
                settings.TreeSnapMode = (GSnapMode)EditorGUILayout.EnumPopup("Snap Mode", settings.TreeSnapMode);
                if (settings.TreeSnapMode == GSnapMode.World)
                {
                    settings.TreeSnapLayerMask = EditorGUILayout.LayerField("Snap Layer", settings.TreeSnapLayerMask);
                }

                GUI.enabled = false;
                EditorGUILayout.LabelField("Tree Instance Count", settings.TreeInstances.Count.ToString());
                GUI.enabled = true;
                if (EditorGUI.EndChangeCheck())
                {
                    data.SetDirty(GTerrainData.DirtyFlags.Foliage);
                }

                EditorGUI.BeginChangeCheck();
                GEditorCommon.Header("Grasses & Details");
                settings.Grasses       = EditorGUILayout.ObjectField("Prototypes", settings.Grasses, typeof(GGrassPrototypeGroup), false) as GGrassPrototypeGroup;
                settings.PatchGridSize = EditorGUILayout.DelayedIntField("Patch Grid Size", settings.PatchGridSize);

                settings.GrassSnapMode = (GSnapMode)EditorGUILayout.EnumPopup("Snap Mode", settings.GrassSnapMode);
                if (settings.GrassSnapMode == GSnapMode.World)
                {
                    settings.GrassSnapLayerMask = EditorGUILayout.LayerField("Snap Layer", settings.GrassSnapLayerMask);
                }
                settings.EnableInteractiveGrass = EditorGUILayout.Toggle("Interactive Grass", settings.EnableInteractiveGrass);
                if (settings.EnableInteractiveGrass)
                {
                    settings.VectorFieldMapResolution = EditorGUILayout.DelayedIntField("Vector Field Map Resolution", settings.VectorFieldMapResolution);
                    settings.BendSensitive            = EditorGUILayout.Slider("Bend Sensitive", settings.BendSensitive, 0f, 1f);
                    settings.RestoreSensitive         = EditorGUILayout.Slider("Restore Sensitive", settings.RestoreSensitive, 0f, 1f);
                }

                GUI.enabled = false;
                EditorGUILayout.LabelField("Grass Instance Count", settings.GrassInstanceCount.ToString());

                GUI.enabled = true;
                if (EditorGUI.EndChangeCheck())
                {
                    data.SetDirty(GTerrainData.DirtyFlags.Foliage);
                    if (settings.EnableInteractiveGrass)
                    {
                        GAnalytics.Record(GAnalytics.ENABLE_INTERACTIVE_GRASS, true);
                    }
                }
            },
                                  menu,
                                  headerWarning);
        }
Example #3
0
        private void DrawFoliageGUI()
        {
            string label = "Foliage";
            string id    = "foliage" + data.Id;

            GenericMenu menu = new GenericMenu();

            menu.AddItem(
                new GUIContent("Reset"),
                false,
                () => { ConfirmAndResetFoliage(); });
            menu.AddItem(
                new GUIContent("Refresh"),
                false,
                () => { data.Foliage.Refresh(); });
            menu.AddItem(
                new GUIContent("Clean Up"),
                false,
                () => { data.Foliage.CleanUp(); });
            menu.AddItem(
                new GUIContent("Clear All Trees"),
                false,
                () => { ConfirmAndClearAllTrees(); });
            menu.AddItem(
                new GUIContent("Clear All Grasses"),
                false,
                () => { ConfirmAndClearAllGrasses(); });

            if (foliageAdditionalContextAction != null && foliageAdditionalContextAction.Count > 0)
            {
                menu.AddSeparator(null);
                for (int i = 0; i < foliageAdditionalContextAction.Count; ++i)
                {
                    menu.AddItem(
                        new GUIContent(foliageAdditionalContextAction[i].Name),
                        foliageAdditionalContextAction[i].IsOn,
                        foliageAdditionalContextAction[i].Action);
                }
            }

            GEditorCommon.Foldout(label, false, id, () =>
            {
                GFoliage settings = data.Foliage;
                EditorGUI.BeginChangeCheck();
                settings.Trees         = EditorGUILayout.ObjectField("Trees", settings.Trees, typeof(GTreePrototypeGroup), false) as GTreePrototypeGroup;
                settings.TreeSnapMode  = (GSnapMode)EditorGUILayout.EnumPopup("Snap Mode", settings.TreeSnapMode);
                SerializedObject so    = new SerializedObject(settings);
                SerializedProperty sp0 = so.FindProperty("treeSnapLayerMask");
                if (settings.TreeSnapMode == GSnapMode.World && sp0 != null)
                {
                    EditorGUILayout.PropertyField(sp0, new GUIContent("Snap Layers"));
                }

                GUI.enabled = false;
                EditorGUILayout.LabelField("Tree Instance Count", settings.TreeInstances.Count.ToString());
                GUI.enabled = true;
                if (EditorGUI.EndChangeCheck())
                {
                    so.ApplyModifiedProperties();
                    data.SetDirty(GTerrainData.DirtyFlags.Foliage);
                }

                sp0.Dispose();

                EditorGUI.BeginChangeCheck();
                settings.Grasses       = EditorGUILayout.ObjectField("Grasses", settings.Grasses, typeof(GGrassPrototypeGroup), false) as GGrassPrototypeGroup;
                settings.PatchGridSize = EditorGUILayout.IntField("Patch Grid Size", settings.PatchGridSize);
                settings.GrassSnapMode = (GSnapMode)EditorGUILayout.EnumPopup("Snap Mode", settings.GrassSnapMode);
                SerializedProperty sp1 = so.FindProperty("grassSnapLayerMask");
                if (settings.GrassSnapMode == GSnapMode.World && sp1 != null)
                {
                    EditorGUILayout.PropertyField(sp1, new GUIContent("Snap Layers"));
                }
                settings.EnableInteractiveGrass = EditorGUILayout.Toggle("Interactive Grass", settings.EnableInteractiveGrass);
                if (settings.EnableInteractiveGrass)
                {
                    settings.VectorFieldMapResolution = EditorGUILayout.DelayedIntField("Vector Field Map Resolution", settings.VectorFieldMapResolution);
                    settings.BendSensitive            = EditorGUILayout.Slider("Bend Sensitive", settings.BendSensitive, 0f, 1f);
                    settings.RestoreSensitive         = EditorGUILayout.Slider("Restore Sensitive", settings.RestoreSensitive, 0f, 1f);
                }

                GUI.enabled = false;
                EditorGUILayout.LabelField("Grass Instance Count", settings.GrassInstanceCount.ToString());

                string storageLabel =
                    settings.EstimatedGrassStorageMB < 1000 ? string.Format("{0} MB", settings.EstimatedGrassStorageMB.ToString("0.00")) :
                    string.Format("{0} GB", (settings.EstimatedGrassStorageMB / 1000f).ToString("0.00"));
                if (settings.EstimatedGrassStorageMB >= 100)
                {
                    storageLabel = string.Format("<color=red>{0}</color>", storageLabel);
                }

                string storageWarning = null;
                if (settings.EstimatedGrassStorageMB >= 100)
                {
                    storageWarning = "Grass storage is quite high, try reduce some instances for better save/load and serialization!";
                }

                EditorGUILayout.LabelField(new GUIContent("Estimated Storage"), new GUIContent(storageLabel, storageWarning), GEditorCommon.RichTextLabel);

                GUI.enabled = true;
                if (EditorGUI.EndChangeCheck())
                {
                    so.ApplyModifiedProperties();
                    data.SetDirty(GTerrainData.DirtyFlags.Foliage);
                    if (settings.EnableInteractiveGrass)
                    {
                        GAnalytics.Record(GAnalytics.ENABLE_INTERACTIVE_GRASS, true);
                    }
                }

                sp1.Dispose();
                so.Dispose();
            }, menu);
        }
Example #4
0
 internal GGrassPatch(GFoliage owner, int indexX, int indexY)
 {
     foliage = owner;
     Index   = new Vector2(indexX, indexY);
 }