예제 #1
0
        public static GTextureStampLayer Create()
        {
            GTextureStampLayer layer = new GTextureStampLayer();

            layer.Color      = Color.white;
            layer.Metallic   = 0;
            layer.Smoothness = 0;
            layer.SplatIndex = 0;
            layer.UpdateCurveTextures();

            return(layer);
        }
예제 #2
0
        private void ConfirmAndRemoveLayerAt(int index)
        {
            GTextureStampLayer layer     = instance.Layers[index];
            string             layerName = string.IsNullOrEmpty(layer.Name) ? ("Layer " + index) : ("Layer " + layer.Name);

            if (EditorUtility.DisplayDialog(
                    "Confirm",
                    "Remove " + layerName + "?",
                    "Yes", "Cancel"))
            {
                instance.Layers.RemoveAt(index);
            }
        }
예제 #3
0
        private void DrawStampLayersGUI()
        {
            string label = "Layers";
            string id    = "layers" + instance.GetInstanceID().ToString();

            GEditorCommon.Foldout(label, true, id, () =>
            {
                List <GTextureStampLayer> layers = instance.Layers;
                for (int i = 0; i < layers.Count; ++i)
                {
                    DrawLayer(layers[i], i);
                    GEditorCommon.Separator();
                }

                Rect r = EditorGUILayout.GetControlRect();
                if (GUI.Button(r, "Add Layer"))
                {
                    GTextureStampLayer layer = GTextureStampLayer.Create();
                    layers.Add(layer);
                }
            });
        }
예제 #4
0
        private void DrawLayer(GTextureStampLayer 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)
            {
                layer.Ignore = EditorGUILayout.Toggle("Ignore", layer.Ignore);
                layer.Name   = EditorGUILayout.TextField("Name", layer.Name);

                if (instance.Channel == GTextureStampChannel.AlbedoMetallicSmoothness)
                {
                    layer.Color      = EditorGUILayout.ColorField("Color", layer.Color);
                    layer.Metallic   = EditorGUILayout.Slider("Metallic", layer.Metallic, 0f, 1f);
                    layer.Smoothness = EditorGUILayout.Slider("Smoothness", layer.Smoothness, 0f, 1f);
                }
                else if (instance.Channel == GTextureStampChannel.Splat)
                {
                    layer.SplatIndex = GEditorCommon.SplatSetSelectionGrid(instance.GroupId, layer.SplatIndex);
                }

                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;
                }
            }
        }
        private void DrawLayer(GTextureStampLayer 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);

                if (instance.Channel == GTextureStampChannel.AlbedoMetallicSmoothness)
                {
                    layer.Color      = EditorGUILayout.ColorField("Color", layer.Color);
                    layer.Metallic   = EditorGUILayout.Slider("Metallic", layer.Metallic, 0f, 1f);
                    layer.Smoothness = EditorGUILayout.Slider("Smoothness", layer.Smoothness, 0f, 1f);
                }
                else if (instance.Channel == GTextureStampChannel.Splat)
                {
                    layer.SplatIndex = GEditorCommon.SplatSetSelectionGrid(instance.GroupId, layer.SplatIndex);
                }

                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);
        }