public static GFoliageStampLayer Create()
        {
            GFoliageStampLayer layer = new GFoliageStampLayer();

            layer.VisualizeColor    = GGriffinSettings.Instance.StampToolSettings.VisualizeColor;
            layer.StampTrees        = true;
            layer.TreeIndices       = null;
            layer.StampGrasses      = false;
            layer.GrassIndices      = null;
            layer.TreeInstanceCount = 1000;
            layer.MinRotation       = GGriffinSettings.Instance.StampToolSettings.MinRotation;
            layer.MaxRotation       = GGriffinSettings.Instance.StampToolSettings.MaxRotation;
            layer.MinScale          = GGriffinSettings.Instance.StampToolSettings.MinScale;
            layer.MaxScale          = GGriffinSettings.Instance.StampToolSettings.MaxScale;

            layer.UpdateCurveTextures();
            return(layer);
        }
Пример #2
0
        public static GFoliageStampLayer Create()
        {
            GFoliageStampLayer layer = new GFoliageStampLayer();

            layer.StampTrees        = true;
            layer.TreeIndices       = null;
            layer.StampGrasses      = false;
            layer.GrassIndices      = null;
            layer.TreeInstanceCount = 1000;

#if UNITY_EDITOR
            layer.VisualizeColor = GEditorSettings.Instance.stampTools.visualizeColor;
            layer.MinRotation    = GEditorSettings.Instance.stampTools.minRotation;
            layer.MaxRotation    = GEditorSettings.Instance.stampTools.maxRotation;
            layer.MinScale       = GEditorSettings.Instance.stampTools.minScale;
            layer.MaxScale       = GEditorSettings.Instance.stampTools.maxScale;
#endif

            layer.UpdateCurveTextures();
            return(layer);
        }
        private void DrawLayer(GFoliageStampLayer layer, int index)
        {
            string label = string.Format("Layer: {0} {1}",
                                         !string.IsNullOrEmpty(layer.Name) ? layer.Name : index.ToString(),
                                         layer.Ignore ? "[Ignored]" : string.Empty);
            string id = "stamperlayer" + index + instance.GetInstanceID().ToString();

            string prefKey  = GEditorCommon.GetProjectRelatedEditorPrefsKey("foldout", id);
            bool   expanded = EditorPrefs.GetBool(prefKey, true);

            Rect headerRect = EditorGUILayout.BeginHorizontal();

            expanded = EditorGUILayout.Foldout(expanded, label);
            EditorPrefs.SetBool(prefKey, expanded);
            GUILayout.FlexibleSpace();
            Rect deleteButtonRect = EditorGUILayout.GetControlRect(GUILayout.Width(15));

            if (headerRect.Contains(Event.current.mousePosition))
            {
                if (GUI.Button(deleteButtonRect, "X", EditorStyles.label))
                {
                    ConfirmAndRemoveLayerAt(index);
                }
            }
            EditorGUILayout.EndHorizontal();

            if (expanded)
            {
                EditorGUI.indentLevel += 1;
                layer.Ignore           = EditorGUILayout.Toggle("Ignore", layer.Ignore);
                layer.Name             = EditorGUILayout.TextField("Name", layer.Name);
                layer.VisualizeColor   = EditorGUILayout.ColorField("Visualize Color", layer.VisualizeColor);
                layer.MinRotation      = EditorGUILayout.FloatField("Min Rotation", layer.MinRotation);
                layer.MaxRotation      = EditorGUILayout.FloatField("Max Rotation", layer.MaxRotation);
                layer.MinScale         = GEditorCommon.InlineVector3Field("Min Scale", layer.MinScale);
                layer.MaxScale         = GEditorCommon.InlineVector3Field("Max Scale", layer.MaxScale);

                layer.StampTrees = EditorGUILayout.Toggle("Stamp Trees", layer.StampTrees);
                if (layer.StampTrees)
                {
                    EditorGUI.indentLevel  += 1;
                    layer.TreeIndices       = GEditorCommon.TreeSetMultiSelectionGrid(instance.GroupId, layer.TreeIndices);
                    layer.TreeInstanceCount = EditorGUILayout.IntField("Instance Count", layer.TreeInstanceCount);
                    EditorGUI.indentLevel  -= 1;
                }
                layer.StampGrasses = EditorGUILayout.Toggle("Stamp Grasses", layer.StampGrasses);
                if (layer.StampGrasses)
                {
                    EditorGUI.indentLevel   += 1;
                    layer.GrassIndices       = GEditorCommon.GrassSetMultiSelectionGrid(instance.GroupId, layer.GrassIndices);
                    layer.GrassInstanceCount = EditorGUILayout.IntField("Instance Count", layer.GrassInstanceCount);
                    EditorGUI.indentLevel   -= 1;
                }

                layer.BlendHeight = EditorGUILayout.Toggle("Blend Height", layer.BlendHeight);
                if (layer.BlendHeight)
                {
                    EditorGUI.indentLevel += 1;
                    layer.MinHeight        = EditorGUILayout.FloatField("Min", layer.MinHeight);
                    layer.MaxHeight        = EditorGUILayout.FloatField("Max", layer.MaxHeight);
                    EditorGUI.BeginChangeCheck();
                    layer.HeightTransition = EditorGUILayout.CurveField("Transition", layer.HeightTransition, Color.red, new Rect(0, 0, 1, 1));
                    if (EditorGUI.EndChangeCheck())
                    {
                        layer.UpdateCurveTextures();
                    }
                    EditorGUI.indentLevel -= 1;
                }

                layer.BlendSlope = EditorGUILayout.Toggle("Blend Slope", layer.BlendSlope);
                if (layer.BlendSlope)
                {
                    EditorGUI.indentLevel += 1;
                    layer.NormalMapMode    = (GNormalMapMode)EditorGUILayout.EnumPopup("Mode", layer.NormalMapMode);
                    layer.MinSlope         = EditorGUILayout.FloatField("Min", layer.MinSlope);
                    layer.MaxSlope         = EditorGUILayout.FloatField("Max", layer.MaxSlope);
                    EditorGUI.BeginChangeCheck();
                    layer.SlopeTransition = EditorGUILayout.CurveField("Transition", layer.SlopeTransition, Color.red, new Rect(0, 0, 1, 1));
                    if (EditorGUI.EndChangeCheck())
                    {
                        layer.UpdateCurveTextures();
                    }
                    EditorGUI.indentLevel -= 1;
                }

                layer.BlendNoise = EditorGUILayout.Toggle("Blend Noise", layer.BlendNoise);
                if (layer.BlendNoise)
                {
                    EditorGUI.indentLevel += 1;
                    layer.NoiseOrigin      = GEditorCommon.InlineVector2Field("Origin", layer.NoiseOrigin);
                    layer.NoiseFrequency   = EditorGUILayout.FloatField("Frequency", layer.NoiseFrequency);
                    layer.NoiseLacunarity  = EditorGUILayout.FloatField("Lacunarity", layer.NoiseLacunarity);
                    layer.NoisePersistence = EditorGUILayout.Slider("Persistence", layer.NoisePersistence, 0.01f, 1f);
                    layer.NoiseOctaves     = EditorGUILayout.IntSlider("Octaves", layer.NoiseOctaves, 1, 4);
                    EditorGUI.BeginChangeCheck();
                    layer.NoiseRemap = EditorGUILayout.CurveField("Remap", layer.NoiseRemap, Color.red, new Rect(0, 0, 1, 1));
                    if (EditorGUI.EndChangeCheck())
                    {
                        layer.UpdateCurveTextures();
                    }
                    EditorGUI.indentLevel -= 1;
                }

                EditorGUI.indentLevel -= 1;
            }
        }
Пример #4
0
        private void DrawLayer(GFoliageStampLayer layer, int index)
        {
            string label = string.Format("Layer: {0} {1}",
                                         !string.IsNullOrEmpty(layer.Name) ? layer.Name : index.ToString(),
                                         layer.Ignore ? "[Ignored]" : string.Empty);
            string id = "stamperlayer" + index + instance.GetInstanceID().ToString();

            GenericMenu menu = new GenericMenu();

            menu.AddItem(
                new GUIContent("Remove"),
                false,
                () =>
            {
                ConfirmAndRemoveLayerAt(index);
            });

            GEditorCommon.Foldout(label, false, id, () =>
            {
                EditorGUI.indentLevel -= 1;
                layer.Ignore           = EditorGUILayout.Toggle("Ignore", layer.Ignore);
                layer.Name             = EditorGUILayout.TextField("Name", layer.Name);
                layer.VisualizeColor   = EditorGUILayout.ColorField("Visualize Color", layer.VisualizeColor);
                layer.MinRotation      = EditorGUILayout.FloatField("Min Rotation", layer.MinRotation);
                layer.MaxRotation      = EditorGUILayout.FloatField("Max Rotation", layer.MaxRotation);
                layer.MinScale         = GEditorCommon.InlineVector3Field("Min Scale", layer.MinScale);
                layer.MaxScale         = GEditorCommon.InlineVector3Field("Max Scale", layer.MaxScale);

                layer.StampTrees = EditorGUILayout.Toggle("Stamp Trees", layer.StampTrees);
                if (layer.StampTrees)
                {
                    EditorGUI.indentLevel  += 1;
                    layer.TreeIndices       = GEditorCommon.TreeSetMultiSelectionGrid(instance.GroupId, layer.TreeIndices);
                    layer.TreeInstanceCount = EditorGUILayout.IntField("Instance Count Per Terrain", layer.TreeInstanceCount);
                    EditorGUI.indentLevel  -= 1;
                }
                layer.StampGrasses = EditorGUILayout.Toggle("Stamp Grasses", layer.StampGrasses);
                if (layer.StampGrasses)
                {
                    EditorGUI.indentLevel   += 1;
                    layer.GrassIndices       = GEditorCommon.GrassSetMultiSelectionGrid(instance.GroupId, layer.GrassIndices);
                    layer.GrassInstanceCount = EditorGUILayout.IntField("Instance Count Per Terrain", layer.GrassInstanceCount);
                    EditorGUI.indentLevel   -= 1;
                }

                layer.BlendHeight = EditorGUILayout.Toggle("Blend Height", layer.BlendHeight);
                if (layer.BlendHeight)
                {
                    EditorGUI.indentLevel += 1;
                    layer.MinHeight        = EditorGUILayout.FloatField("Min", layer.MinHeight);
                    layer.MaxHeight        = EditorGUILayout.FloatField("Max", layer.MaxHeight);
                    EditorGUI.BeginChangeCheck();
                    layer.HeightTransition = EditorGUILayout.CurveField("Transition", layer.HeightTransition, Color.red, new Rect(0, 0, 1, 1));
                    if (EditorGUI.EndChangeCheck())
                    {
                        layer.UpdateCurveTextures();
                    }
                    EditorGUI.indentLevel -= 1;
                }

                layer.BlendSlope = EditorGUILayout.Toggle("Blend Slope", layer.BlendSlope);
                if (layer.BlendSlope)
                {
                    EditorGUI.indentLevel += 1;
                    layer.NormalMapMode    = (GNormalMapMode)EditorGUILayout.EnumPopup("Mode", layer.NormalMapMode);
                    layer.MinSlope         = EditorGUILayout.FloatField("Min", layer.MinSlope);
                    layer.MaxSlope         = EditorGUILayout.FloatField("Max", layer.MaxSlope);
                    EditorGUI.BeginChangeCheck();
                    layer.SlopeTransition = EditorGUILayout.CurveField("Transition", layer.SlopeTransition, Color.red, new Rect(0, 0, 1, 1));
                    if (EditorGUI.EndChangeCheck())
                    {
                        layer.UpdateCurveTextures();
                    }
                    EditorGUI.indentLevel -= 1;
                }

                layer.BlendNoise = EditorGUILayout.Toggle("Blend Noise", layer.BlendNoise);
                if (layer.BlendNoise)
                {
                    EditorGUI.indentLevel += 1;
                    layer.NoiseOrigin      = GEditorCommon.InlineVector2Field("Origin", layer.NoiseOrigin);
                    layer.NoiseFrequency   = EditorGUILayout.FloatField("Frequency", layer.NoiseFrequency);
                    layer.NoiseLacunarity  = EditorGUILayout.FloatField("Lacunarity", layer.NoiseLacunarity);
                    layer.NoisePersistence = EditorGUILayout.Slider("Persistence", layer.NoisePersistence, 0.01f, 1f);
                    layer.NoiseOctaves     = EditorGUILayout.IntSlider("Octaves", layer.NoiseOctaves, 1, 4);
                    EditorGUI.BeginChangeCheck();
                    layer.NoiseRemap = EditorGUILayout.CurveField("Remap", layer.NoiseRemap, Color.red, new Rect(0, 0, 1, 1));
                    if (EditorGUI.EndChangeCheck())
                    {
                        layer.UpdateCurveTextures();
                    }
                    EditorGUI.indentLevel -= 1;
                }
                EditorGUI.indentLevel += 1;
            },
                                  menu);
        }