コード例 #1
0
        public void Draw()
        {
            noiseType = (NoiseType)EditorGUILayout.EnumPopup("Fill", noiseType);

            if (noiseType == NoiseType.PERLIN)
            {
                gradient = EditorGUILayout.GradientField("Color", gradient);

                octaves                = EditorGUILayout.IntSlider("Octaves", octaves, 1, 10);
                perlinNoiseScale       = EditorGUILayout.Slider("Scale", perlinNoiseScale, 0.01f, 1000f);
                perlinNoisePersistence = EditorGUILayout.Slider("Persistence", perlinNoisePersistence, 0f, 1f);
                seed = EditorGUILayout.IntSlider("Seed", seed, 1, 100000);
                perlinNoiseOffset = EditorGUILayout.Vector2Field("Offset", perlinNoiseOffset);

                flip = EditorGUILayout.Toggle("Flip", flip);
            }
            else if (noiseType == NoiseType.RANDOM)
            {
                seed      = EditorGUILayout.IntSlider("Seed", seed, 1, 100000);
                useColors = EditorGUILayout.Toggle("Use colors", useColors);
            }
            else if (noiseType == NoiseType.VORONOI)
            {
                voronoiDstType = (VoronoiDistanceMetric)EditorGUILayout.EnumPopup("Distance type", voronoiDstType);
                sites          = EditorGUILayout.IntField("Sites", sites);
                seed           = EditorGUILayout.IntSlider("Seed", seed, 1, 100000);
                useColors      = EditorGUILayout.Toggle("Use colors", useColors);
                renderFlat     = EditorGUILayout.Toggle("Render flat", renderFlat);

                flip = EditorGUILayout.Toggle("Flip", flip);
            }
        }
コード例 #2
0
        private void OnGUI()
        {
            GUILayout.Space(5);
            GUILayout.Label("Texture Ramp", EditorStyles.boldLabel);
            textureName = EditorGUILayout.TextField("Name", textureName);
            gradient    = EditorGUILayout.GradientField("Gradient", gradient);

            GUILayout.Space(15);
            GUILayout.Label("Texture Size", EditorStyles.boldLabel);
            isSquare = EditorGUILayout.Toggle("Texture is Square", isSquare);
            GUILayout.Space(5);
            if (isSquare)
            {
                size = EditorGUILayout.IntField("Size", size);
            }
            else
            {
                xSize = EditorGUILayout.IntField("Lenght", xSize);
                ySize = EditorGUILayout.IntField("Height", ySize);
            }

            GUILayout.Space(15);
            if (GUILayout.Button("Generate Texture Ramp"))
            {
                CreateGradient();
            }
        }
コード例 #3
0
ファイル: EditorGUILayoutUtil.cs プロジェクト: uiopsczc/Test
        public static object Field(string label, Type type, object fieldValue)
        {
            if (type == typeof(string))
            {
                return(EditorGUILayout.TextField(label, (string)fieldValue));
            }
            if (type == typeof(float))
            {
                return(EditorGUILayout.FloatField(label, (float)fieldValue));
            }
            if (type == typeof(int))
            {
                return(EditorGUILayout.IntField(label, (int)fieldValue));
            }
            if (type == typeof(Bounds))
            {
                return(EditorGUILayout.BoundsField(label, (Bounds)fieldValue));
            }

            if (type == typeof(Color))
            {
                return(EditorGUILayout.ColorField(label, (Color)fieldValue));
            }
            if (type == typeof(AnimationCurve))
            {
                return(EditorGUILayout.CurveField(label, (AnimationCurve)fieldValue));
            }
            if (type == typeof(Gradient))
            {
                return(EditorGUILayout.GradientField(label, (Gradient)fieldValue));
            }
            if (type == typeof(long))
            {
                return(EditorGUILayout.LongField(label, (long)fieldValue));
            }
            if (fieldValue is Object o)
            {
                using (new EditorGUILayoutBeginHorizontalScope())
                {
                    EditorGUILayout.LabelField(label, GUILayout.Width(100));
                    object result = EditorGUILayout.ObjectField(o, type);
                    return(result);
                }
            }

            if (type == typeof(Rect))
            {
                return(EditorGUILayout.RectField(label, (Rect)fieldValue));
            }
            if (type == typeof(Vector2))
            {
                return(EditorGUILayout.Vector2Field(label, (Vector2)fieldValue));
            }
            if (type == typeof(Vector3))
            {
                return(EditorGUILayout.Vector3Field(label, (Vector3)fieldValue));
            }
            LogCat.LogError(string.Format("不支持该类型的field:{0}", type));
            return(null);
        }
コード例 #4
0
    private void OnGUI()
    {
        if (m_Gradient == null)
        {
            m_Gradient = new Gradient()
            {
                colorKeys = new GradientColorKey[]
                {
                    new GradientColorKey {
                        color = Color.black, time = 0f
                    },
                    new GradientColorKey {
                        color = Color.white, time = 1f
                    },
                }
            };
        }
        m_Gradient = EditorGUILayout.GradientField(m_Gradient);

        if (GUILayout.Button("Save"))
        {
            var path = EditorUtility.SaveFilePanelInProject("Save Gradient as png", "New Gradient", "png", "");
            SaveGradient(Path.GetFullPath(path));
        }
    }
コード例 #5
0
        private void DrawShadingDefaultSettings()
        {
            string label = "Shading Default";
            string id    = "runtime-settings-shading-default";

            GEditorCommon.Foldout(label, false, id, () =>
            {
                GEditorCommon.Header("Color Map & Gradient Lookup");
                instance.shadingDefault.albedoMapResolution   = EditorGUILayout.IntField("Albedo Map Resolution", instance.shadingDefault.albedoMapResolution);
                instance.shadingDefault.metallicMapResolution = EditorGUILayout.IntField("Metallic Map Resolution", instance.shadingDefault.metallicMapResolution);

                instance.shadingDefault.colorByNormal   = EditorGUILayout.GradientField("Color By Normal", instance.shadingDefault.colorByNormal);
                instance.shadingDefault.colorBlendCurve = EditorGUILayout.CurveField("Blend By Height", instance.shadingDefault.colorBlendCurve, Color.red, new Rect(0, 0, 1, 1));
                instance.shadingDefault.colorByHeight   = EditorGUILayout.GradientField("Color By Height", instance.shadingDefault.colorByHeight);

                GEditorCommon.Header("Splats");
                instance.shadingDefault.splats = EditorGUILayout.ObjectField("Prototypes", instance.shadingDefault.splats, typeof(GSplatPrototypeGroup), false) as GSplatPrototypeGroup;
                instance.shadingDefault.splatControlResolution = EditorGUILayout.DelayedIntField("Control Map Resolution", instance.shadingDefault.splatControlResolution);

                GEditorCommon.Header("Properties Name");
                instance.shadingDefault.albedoMapPropertyName       = EditorGUILayout.TextField("Albedo Map", instance.shadingDefault.albedoMapPropertyName);
                instance.shadingDefault.metallicMapPropertyName     = EditorGUILayout.TextField("Metallic Map", instance.shadingDefault.metallicMapPropertyName);
                instance.shadingDefault.colorByHeightPropertyName   = EditorGUILayout.TextField("Color By Height", instance.shadingDefault.colorByHeightPropertyName);
                instance.shadingDefault.colorByNormalPropertyName   = EditorGUILayout.TextField("Color By Normal", instance.shadingDefault.colorByNormalPropertyName);
                instance.shadingDefault.colorBlendPropertyName      = EditorGUILayout.TextField("Color Blend", instance.shadingDefault.colorBlendPropertyName);
                instance.shadingDefault.dimensionPropertyName       = EditorGUILayout.TextField("Dimension", instance.shadingDefault.dimensionPropertyName);
                instance.shadingDefault.splatControlMapPropertyName = EditorGUILayout.TextField("Splat Control Map", instance.shadingDefault.splatControlMapPropertyName);
                instance.shadingDefault.splatMapPropertyName        = EditorGUILayout.TextField("Splat Map", instance.shadingDefault.splatMapPropertyName);
                instance.shadingDefault.splatNormalPropertyName     = EditorGUILayout.TextField("Splat Normal Map", instance.shadingDefault.splatNormalPropertyName);
                instance.shadingDefault.splatMetallicPropertyName   = EditorGUILayout.TextField("Splat Metallic", instance.shadingDefault.splatMetallicPropertyName);
                instance.shadingDefault.splatSmoothnessPropertyName = EditorGUILayout.TextField("Splat Smoothness", instance.shadingDefault.splatSmoothnessPropertyName);
            });
        }
コード例 #6
0
        internal static Gradient GradientField(GUIContent gc, Gradient value)
        {
            GUILayout.Label(gc);

            object out_gradient = EditorGUILayout.GradientField(PolyGUI.TempContent("", gc.tooltip), value, null);

            return((Gradient)out_gradient);
        }
コード例 #7
0
        private static Gradient DrawGradientProperty(Gradient gradient)
        {
#if UNITY_2018_3
            return(EditorGUILayout.GradientField(gradient));
#else
            var method = typeof(EditorGUI).GetMethods(BindingFlags.NonPublic | BindingFlags.Static).First(t => t.Name == "GradientField");
            return((Gradient)method.Invoke(null, new object[] { EditorGUILayout.GetControlRect(), gradient }));
#endif
        }
コード例 #8
0
        public static Gradient GradientField(string label, Gradient value, params GUILayoutOption[] options)
        {
#if UNITY_2018_3_OR_NEWER
            return(EditorGUILayout.GradientField(label, value, options));
#else
            MethodInfo method = EditorGUILayoutEx.Type.GetMethod("GradientField", BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof(string), typeof(Gradient), typeof(GUILayoutOption[]) }, null);
            return((Gradient)method.Invoke(Type, new object[] { label, value, options }));
#endif
        }
コード例 #9
0
ファイル: DreamteckEditorGUI.cs プロジェクト: Wanyea/Galaga
        public static Gradient GradientField(string label, Gradient gradient, params GUILayoutOption[] options)
        {
#if UNITY_2018_3_OR_NEWER
            return(EditorGUILayout.GradientField(label, gradient, options));
#else
            gradient = (Gradient)gradientFieldMethod.Invoke(null, new object[] { label, gradient, options });
            return(gradient);
#endif
        }
コード例 #10
0
 //
 public static void DrawGradientField(string title, ref Gradient value, Action <Gradient> changeHandler)
 {
     DrawField(title, ref value, (v) =>
     {
         return(EditorGUILayout.GradientField(v));
     }, (v) => { });
     // 因为Gradient 不好比较 就直接执行了
     changeHandler(value);
 }
コード例 #11
0
 public void Draw(object value, FieldInfo field = null)
 {
     if (field == null)
     {
         EditorGUILayout.GradientField((Gradient)value);
     }
     else
     {
         EditorGUILayout.GradientField(field.Name, (Gradient)value);
     }
 }
コード例 #12
0
    public override void OnInspectorGUI()
    {
        _chances              = EditorStyles.whiteLabel;
        _chances.fontStyle    = FontStyle.Bold;
        _chances.padding.left = 15;

        EditorGUILayout.LabelField("Настройка цветов редкости", _chances);

        EditorGUILayout.BeginVertical("Box");

        for (int i = 0; i < 3; i++)
        {
            _rarity = (Bonus.RarityType)i;
            if (_rarityColors.GetArrayElementAtIndex(i) == null)
            {
                _rarityColors.InsertArrayElementAtIndex(i);
                _rarityColors.GetArrayElementAtIndex(i).colorValue = EditorGUILayout.ColorField(_rarity.ToString(), _rarityColors.GetArrayElementAtIndex(i).colorValue);
            }
            else
            {
                _rarityColors.GetArrayElementAtIndex(i).colorValue = EditorGUILayout.ColorField(_rarity.ToString(), _rarityColors.GetArrayElementAtIndex(i).colorValue);
            }
        }
        EditorGUILayout.EndVertical();

        EditorGUILayout.LabelField("Настройка шансов выпадения", _chances);

        EditorGUILayout.BeginVertical("Box");
        EditorGUILayout.GradientField("Астеройдов %", _randomizer.AsteroidChances);
        EditorGUILayout.HelpBox("Small - Red; Medium - Green; Big - Blue", MessageType.Info, true);
        EditorGUILayout.GradientField("Редкости %", _randomizer.RarityChances);
        EditorGUILayout.HelpBox("Common - Red; Rare - Green; Legend - Blue", MessageType.Info, true);
        EditorGUILayout.GradientField("Бонусов %", _randomizer.BonusChance);
        EditorGUILayout.HelpBox("Damage - Red; Cooldown - Green; Speed - Blue", MessageType.Info, true);
        //EditorGUILayout.GradientField("Главный %", _randomizer.SpawnChances);
        EditorGUILayout.EndVertical();

        EditorGUILayout.Space(8);
        EditorGUILayout.LabelField("Шансы спавна бонусов", _chances);

        EditorGUILayout.BeginVertical("Box");
        _bonusSpawnChance.floatValue =
            EditorGUILayout.Slider("Обычный бонус %", _bonusSpawnChance.floatValue, 0f, 100f - (_weaponUpgradeSpawnChance.floatValue + _weaponBonusSpawnChance.floatValue + _shieldChargeSpawnChance.floatValue));
        _weaponUpgradeSpawnChance.floatValue =
            EditorGUILayout.Slider("Апгрейд оружия %", _weaponUpgradeSpawnChance.floatValue, 0f, 100f - (_bonusSpawnChance.floatValue + _weaponBonusSpawnChance.floatValue + _shieldChargeSpawnChance.floatValue));
        _weaponBonusSpawnChance.floatValue =
            EditorGUILayout.Slider("Бонус оружия %", _weaponBonusSpawnChance.floatValue, 0f, 100f - (_bonusSpawnChance.floatValue + _weaponUpgradeSpawnChance.floatValue + _shieldChargeSpawnChance.floatValue));
        _shieldChargeSpawnChance.floatValue =
            EditorGUILayout.Slider("Заряд щита %", _shieldChargeSpawnChance.floatValue, 0f, 100f - (_bonusSpawnChance.floatValue + _weaponUpgradeSpawnChance.floatValue + _weaponBonusSpawnChance.floatValue));
        EditorGUILayout.EndVertical();

        serializedObject.ApplyModifiedProperties();
    }
コード例 #13
0
        private void OnGUI()
        {
            var r = _editor.FieldRenderer;

            r.ShowField         = EditorGUILayout.Toggle("Show Field:", r.ShowField);
            r.FieldSamplingRate = EditorGUILayout.FloatField("Sampling Rate:", r.FieldSamplingRate);
            r.MinSize           = EditorGUILayout.Slider("Point Min Size:", r.MinSize, 0, r.MaxSize);
            r.MaxSize           = EditorGUILayout.Slider("Point Max Size:", r.MaxSize, r.MinSize, 1);
            r.MinValue          = EditorGUILayout.Slider("Min Value:", r.MinValue, 0, r.MaxValue);
            r.MaxValue          = EditorGUILayout.Slider("Max Value:", r.MaxValue, r.MinValue, 1);
            r.Gradient          = EditorGUILayout.GradientField("Color Map:", r.Gradient);
        }
コード例 #14
0
    void OnGUI()
    {
        m_gradient     = EditorGUILayout.GradientField(m_gradient);
        m_textureWidth = EditorGUILayout.IntField(m_textureWidth);

        if (GUILayout.Button("Generate"))
        {
            string path    = EditorUtility.SaveFilePanel("Save", "", "Gradient", "png");
            var    pngData = m_gradient.CreateTexture(m_textureWidth).EncodeToPNG();
            File.WriteAllBytes(path, pngData);
        }
    }
コード例 #15
0
    private void OnGUI()
    {
        input = (Texture2D)EditorGUILayout.ObjectField("input", input, typeof(Texture2D), false);


        EditorGUILayout.BeginHorizontal();
        if (input)
        {
            EditorGUILayout.BeginVertical();
            if (GUILayout.Button("Init"))
            {
                InitTransform();
            }

            EditorGUI.DrawPreviewTexture(EditorGUILayout.GetControlRect(false, input.height), input);
            EditorGUILayout.EndVertical();


            EditorGUILayout.BeginVertical();

            gradient = EditorGUILayout.GradientField(gradient);

            swirl = EditorGUILayout.Slider(swirl, 0, 1);
            if (GUILayout.Button("Swirl"))
            {
                Swirl();
            }
            if (GUILayout.Button("HorseShoe"))
            {
                HorseShoe();
            }
            if (transform != null)
            {
                EditorGUI.DrawPreviewTexture(EditorGUILayout.GetControlRect(false, transform.height), transform);
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical();
            if (transform != null && GUILayout.Button("Render"))
            {
                Render();
            }
            if (render != null)
            {
                EditorGUI.DrawPreviewTexture(EditorGUILayout.GetControlRect(false, render.height), render);
            }

            EditorGUILayout.EndVertical();
        }

        EditorGUILayout.EndHorizontal();
    }
コード例 #16
0
    private void OnGUI()
    {
        type     = (GradientType)EditorGUILayout.EnumPopup("Type", type);
        gradient = EditorGUILayout.GradientField("Gradient", gradient);
        width    = EditorGUILayout.IntSlider("Width", width, 2, 2048);
        height   = EditorGUILayout.IntSlider("Height", height, 2, 2048);

        if (GUILayout.Button("Generate"))
        {
            Texture2D texture = Generate();
            Save(texture);
        }
    }
コード例 #17
0
        protected override void DrawParticleSystemParameter(int index, ParticleSystem ps)
        {
            base.DrawParticleSystemParameter(index, ps);

            var main       = ps.main;
            var startColor = main.startColor;

            EditorGUI.BeginChangeCheck();
            switch (startColor.mode)
            {
            case ParticleSystemGradientMode.Color:
                startColor.color = EditorGUILayout.ColorField("Color", startColor.color);
                break;

            case ParticleSystemGradientMode.Gradient:
                if (startColor.gradient != null)
                {
                    EditorGUILayout.GradientField("Gradient", startColor.gradient);
                }
                break;

            case ParticleSystemGradientMode.TwoColors:
                startColor.colorMax = EditorGUILayout.ColorField("Color(Max)", startColor.colorMax);
                startColor.colorMin = EditorGUILayout.ColorField("Color(Min)", startColor.colorMin);
                break;

            case ParticleSystemGradientMode.TwoGradients:
                if (startColor.gradientMin != null)
                {
                    EditorGUILayout.GradientField("Gradient(Min)", startColor.gradientMin);
                }
                if (startColor.gradientMax != null)
                {
                    EditorGUILayout.GradientField("Gradient(Max)", startColor.gradientMax);
                }
                break;

            case ParticleSystemGradientMode.RandomColor:
                EditorGUILayout.GradientField("Random Color", startColor.gradient);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(ps, "Change StartColor");
                main.startColor = startColor;
            }
        }
コード例 #18
0
    private void OnGUI()
    {
        EditorGUILayout.LabelField("GradientGenerater");
        EditorGUILayout.Space(10);

        var oldColor = GUI.backgroundColor;

        GUI.backgroundColor = m_HDR ? Color.red : Color.white;
        if (GUILayout.Button("HDR"))
        {
            m_HDR = !m_HDR;
        }
        GUI.backgroundColor = oldColor;

        GUILayoutOption[] options = new[] { GUILayout.Width(300), GUILayout.Height(50) };
        m_Gradient = EditorGUILayout.GradientField(new GUIContent()
        {
            text = "Field"
        }, m_Gradient, m_HDR, options);

        if (GUILayout.Button("Generate Texture"))
        {
            m_Texture2D = new Texture2D(32, 4, TextureFormat.ARGB32, false);

            Color[] colors = new Color[32 * 4];
            for (int y = 0; y < 4; ++y)
            {
                for (int x = 0; x < 32; ++x)
                {
                    colors[(y * 32) + x] = m_Gradient.Evaluate((x + 1.0f) / 32.0f);
                }
            }

            m_Texture2D.SetPixels(colors);
            m_Texture2D.Apply();
        }

        if (m_Texture2D != null)
        {
            EditorGUI.DrawPreviewTexture(new Rect(90, 170, 150, 20), m_Texture2D);

            if (GUILayout.Button("Export"))
            {
                SaveTextureAsPNG(m_Texture2D, "Assets/Project/Graphic/Textures/GradientTex.png");
            }
        }
        else
        {
            EditorGUI.DrawRect(new Rect(90, 170, 150, 20), Color.white);
        }
    }
コード例 #19
0
    private void OnGUI()
    {
        if (!fogSettings)
        {
            return;
        }

        if (fogSettingsNotFoundOnDisk && !String.IsNullOrEmpty(currentScene.path))
        {
            DrawCreateFogSettingsAssetButton();
        }

        EditorGUILayout.LabelField(headerContent, EditorStyles.boldLabel, GUILayout.Height(20));

        EditorGUI.BeginChangeCheck(); {
            isEnabled = EditorGUILayout.Toggle(isEnabledText, fogSettings.isEnabled);
            EditorGUI.BeginChangeCheck(); {
                colorMode = (EnhancedFogColorMode)EditorGUILayout.EnumPopup(colorModeText, fogSettings.colorMode);
            } if (EditorGUI.EndChangeCheck())
            {
                gradientTexture = GenerateGradientTexture(gradient, gradientTextureWidth);
            }
            if (fogSettings.colorMode == EnhancedFogColorMode.SingleColor)
            {
                color = EditorGUILayout.ColorField(colorText, fogSettings.color);
            }
            else
            {
                EditorGUI.BeginChangeCheck(); {
                    gradient = EditorGUILayout.GradientField(gradientText, fogSettings.gradient);
                } if (EditorGUI.EndChangeCheck())
                {
                    gradientTexture = GenerateGradientTexture(gradient, gradientTextureWidth);
                }
            }
            mode = (EnhancedFogMode)EditorGUILayout.EnumPopup(modeText, fogSettings.mode);
            if (fogSettings.mode == EnhancedFogMode.Linear)
            {
                startDistance = EditorGUILayout.FloatField(startDistanceText, fogSettings.startDistance);
                endDistance   = EditorGUILayout.FloatField(endDistanceText, fogSettings.endDistance);
            }
            else
            {
                density = EditorGUILayout.FloatField(densityText, fogSettings.density);
            }
        } if (EditorGUI.EndChangeCheck())
        {
            ApplyWindowSettingsToFogSettings(fogSettings);
        }
    }
コード例 #20
0
        private void OnGUI()
        {
            EditorGUILayout.LabelField(new GUIContent("Data Information"), EditorStyles.boldLabel);
            dataFile = (TextAsset)EditorGUILayout.ObjectField("Data File", dataFile, typeof(TextAsset), false);

            EditorGUILayout.Space();

            EditorGUILayout.LabelField(new GUIContent("Key Information"), EditorStyles.boldLabel);
            keyFormat = (DataKeyFormat)EditorGUILayout.EnumPopup(keyFormat);

            switch (keyFormat)
            {
            case DataKeyFormat.JsonLatLngArrays:
                latitudeKey  = EditorGUILayout.TextField("Latitude Array Key", latitudeKey);
                longitudeKey = EditorGUILayout.TextField("Longitude Array Key", longitudeKey);
                break;

            case DataKeyFormat.JsonLatAndLngKeys:
            case DataKeyFormat.Csv:
                latitudeKey  = EditorGUILayout.TextField("Latitude Key", latitudeKey);
                longitudeKey = EditorGUILayout.TextField("Longitude Key", longitudeKey);
                break;

            case DataKeyFormat.JsonSingleLatLngArray:
                latitudeKey = EditorGUILayout.TextField("Coordinates Array Key", latitudeKey);
                break;
            }

            EditorGUILayout.Space();

            EditorGUILayout.LabelField(new GUIContent("Heatmap Information"), EditorStyles.boldLabel);
            mPlanetRadius = EditorGUILayout.FloatField("Planet Radius (meters)", mPlanetRadius);
            kmRange       = EditorGUILayout.FloatField("Range (kilometers)", kmRange);
            startValue    = EditorGUILayout.IntSlider("Start Value", startValue, 0, 100);
            endValue      = EditorGUILayout.IntSlider("End Value", endValue, 0, 100);
            heatmapSize   = EditorGUILayout.Vector2Field("Heatmap Size", heatmapSize);

            EditorGUILayout.Space();

            colors = EditorGUILayout.GradientField("Colors", colors);

            EditorGUILayout.Space(20);

            if (GUILayout.Button("Generate Heatmap"))
            {
                OnWizardCreate();
            }
        }
コード例 #21
0
    public override void OnInspectorGUI()
    {
        OVRPassthroughLayer layer = (OVRPassthroughLayer)target;

        layer.projectionSurfaceType = (OVRPassthroughLayer.ProjectionSurfaceType)EditorGUILayout.EnumPopup(
            new GUIContent("Projection Surface", "The type of projection surface for this Passthrough layer"),
            layer.projectionSurfaceType);

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Compositing", EditorStyles.boldLabel);
        layer.overlayType      = (OVROverlay.OverlayType)EditorGUILayout.EnumPopup(new GUIContent("Placement", "Whether this overlay should layer behind the scene or in front of it"), layer.overlayType);
        layer.compositionDepth = EditorGUILayout.IntField(new GUIContent("Composition Depth", "Depth value used to sort layers in the scene, smaller value appears in front"), layer.compositionDepth);

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Style", EditorStyles.boldLabel);

        layer.textureOpacity = EditorGUILayout.Slider("Opacity", layer.textureOpacity, 0, 1);

        EditorGUILayout.Space();

        layer.edgeRenderingEnabled = EditorGUILayout.Toggle(
            new GUIContent("Edge Rendering", "Highlight salient edges in the camera images in a specific color"),
            layer.edgeRenderingEnabled);
        layer.edgeColor = EditorGUILayout.ColorField("Edge Color", layer.edgeColor);

        EditorGUILayout.Space();

        System.Func <System.Enum, bool> hideCustomColorMapOption = option => (ColorMapEditorType)option != ColorMapEditorType.Custom;
        layer.colorMapEditorType = (ColorMapEditorType)EditorGUILayout.EnumPopup(
            new GUIContent("Color Map"),
            layer.colorMapEditorType,
            hideCustomColorMapOption,
            false);

        if (layer.colorMapEditorType == ColorMapEditorType.Controls)
        {
            layer.colorMapEditorContrast   = EditorGUILayout.Slider("Contrast", layer.colorMapEditorContrast, -1, 1);
            layer.colorMapEditorBrightness = EditorGUILayout.Slider("Brightness", layer.colorMapEditorBrightness, -1, 1);
            layer.colorMapEditorPosterize  = EditorGUILayout.Slider("Posterize", layer.colorMapEditorPosterize, 0, 1);
            layer.colorMapEditorGradient   = EditorGUILayout.GradientField("Colorize", layer.colorMapEditorGradient);
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(layer);
        }
    }
コード例 #22
0
        public object DrawAndGetNewValue(Type type, object value, DrawInfo draw, FieldInfo field)
        {
            EditorGUI.BeginDisabledGroup(!draw.Changeable);

            if (draw.ShowNameWidth < 0)
            {
                if (value == null)
                {
                    ObjectDrawerHelper.ShowNull(draw.ShowName, type, ref value);
                }
                else
                {
                    value = EditorGUILayout.GradientField(draw.ShowName, (Gradient)value);
                }
            }
            else if (draw.ShowNameWidth == 0)
            {
                if (value == null)
                {
                    ObjectDrawerHelper.ShowNull(draw.ShowName, type, ref value);
                }
                else
                {
                    value = EditorGUILayout.GradientField((Gradient)value);
                }
            }
            else
            {
                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.LabelField(draw.ShowName, GUILayout.Width(draw.ShowNameWidth));
                if (value == null)
                {
                    ObjectDrawerHelper.ShowNull(draw.ShowName, type, ref value);
                }
                else
                {
                    value = EditorGUILayout.GradientField((Gradient)value);
                }

                EditorGUILayout.EndHorizontal();
            }

            EditorGUI.EndDisabledGroup();
            return(value);
        }
コード例 #23
0
        public override void OnInspectorGUI()
        {
            PropertyField(m_time);
            PropertyField(m_minTime);
            PropertyField(m_maxTime);

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Color and Saturation Gradient", EditorStyles.boldLabel);
            EditorGUILayout.LabelField("Color key = tint color (multiplied)");
            EditorGUILayout.LabelField("Alpha key = saturation");
            EditorGUILayout.LabelField("Max of 8 color keys and 8 alpha keys.");

            gradient = EditorGUILayout.GradientField("Gradient", gradient);
            SetGradientValues();
        }
コード例 #24
0
        void OnGUI()
        {
            gradient = EditorGUILayout.GradientField(gradient);

            int width  = EditorGUILayout.IntField("Width", resolution.x);
            int height = EditorGUILayout.IntField("Height", resolution.y);

            resolution = Int2.Max(Int2.one, new Int2(width, height));

            if (GUILayout.Button("Generate"))
            {
                string path = EditorUtility.SaveFilePanelInProject("Save Gradient as PNG", "Gradient.png", "png", "");
                if (!string.IsNullOrEmpty(path) && !string.IsNullOrWhiteSpace(path))
                {
                    SaveGradient(path);
                }
            }
        }
コード例 #25
0
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();

            if (!TerraConfig.Instance.EditorState.ShowDebugMessages)
            {
                return;
            }

            _tile.PreviewDeviation = EditorGUILayout.IntField("Deviation", _tile.PreviewDeviation);

            if (_tile.PreviewGradient != null)
            {
                EditorGUILayout.GradientField("Biome Gradient", _tile.PreviewGradient);
            }

            if (GUILayout.Button("Preview biome"))
            {
                SetBiomePreviewTexture();
            }

            if (GUILayout.Button("Preview blurred biome map"))
            {
                SetBlurredBiomePreviewTexture();
            }

            if (GUILayout.Button("Export biome map"))
            {
                ExportBiomeMap();
            }

            if (GUILayout.Button("Export blurred biome map"))
            {
                ExportBlurredBiomeMap();
            }

            if (_previewTexture != null)
            {
                int  padding = 4;
                int  width   = Mathf.FloorToInt(EditorGUIUtility.currentViewWidth) - padding * 2;
                Rect ctrl    = EditorGUILayout.GetControlRect(false, width);
                EditorGUI.DrawPreviewTexture(ctrl, _previewTexture);
            }
        }
コード例 #26
0
    public override void OnInspectorGUI()
    {
        _planetSettings = (PlanetSettings)target;

        SerializedObject planetSettings = new SerializedObject(target);

        CustomEditorHelpers.DrawHeader("Planet settings");

        _planetSettings.Resolution = (int)EditorGUILayout.Slider("Resolution", _planetSettings.Resolution, 2, 128);
        _planetSettings.Radius     = (int)EditorGUILayout.Slider("Radius", _planetSettings.Radius, 2, 128);

        EditorGUILayout.PropertyField(planetSettings.FindProperty("NoiseSettings"));

        CustomEditorHelpers.DrawHeader("Color settings");

        _planetSettings.ColorSettings.Gradient =
            EditorGUILayout.GradientField("Gradient", _planetSettings.ColorSettings.Gradient);

        planetSettings.ApplyModifiedProperties();
    }
コード例 #27
0
        private void OnGUI()
        {
            EditorGUILayout.LabelField("Diamond Square", EditorStyles.boldLabel);

            _gradient           = EditorGUILayout.GradientField("Gradient", _gradient);
            _seed               = EditorGUILayout.IntField("Seed", _seed);
            _exponentialMapSize = EditorGUILayout.IntSlider("Map Size (n-Factor)", _exponentialMapSize, 0, 10);
            _gaussRepeatTime    = EditorGUILayout.IntSlider("Gauss Apply count", _gaussRepeatTime, 0, 20);
            _noiseIntensity     = EditorGUILayout.IntField("Noise Intensity", _noiseIntensity);

            if (GUILayout.Button("Generate HeightMap"))
            {
                _heightMap = DiamondSquare.GenerateHeightMap(_exponentialMapSize, _noiseIntensity, _seed);
                _mapSize   = _heightMap.GetLength(0) - 1;
            }

            if (GUILayout.Button("Apply Blur"))
            {
                _heightMap = GaussianBlur.ApplyBlur(_heightMap, _gaussRepeatTime);
            }

            if (GUILayout.Button("Generate Mesh"))
            {
                GenerateMesh();
            }

            if (GUILayout.Button("Generate Terrain"))
            {
                GenerateTerrain();
            }

            if (GUILayout.Button("Delete Grid"))
            {
                DeleteGrid();
            }

            if (GUILayout.Button("Add Octave"))
            {
                AddOctave();
            }
        }
コード例 #28
0
        public void Draw()
        {
            gradientType = (GradientType)EditorGUILayout.EnumPopup("Fill", gradientType);

            gradient = EditorGUILayout.GradientField("Color", gradient);

            if (gradientType == GradientType.RADIAL)
            {
                radialMaskThreshold = EditorGUILayout.FloatField("Mask threshold", radialMaskThreshold);

                if (GUI.changed)
                {
                    if (radialMaskThreshold < 0)
                    {
                        radialMaskThreshold = 0;
                    }
                }
            }

            flip = EditorGUILayout.Toggle("Flip", flip);
        }
コード例 #29
0
        private void LightRampGradient()
        {
            var count = Mathf.RoundToInt(_cellProperties.LightRampSize.floatValue);

            var gradient = new Gradient();

            if (count > 0)
            {
                var keys = new GradientColorKey[count];
                for (var i = 0; i < count; i++)
                {
                    keys[i].color = _cellProperties.LightRampColors[i].colorValue;
                    keys[i].time  = _cellProperties.LightRampValues[i].floatValue;
                }

                gradient.colorKeys = keys;
            }

            gradient.mode = GradientMode.Fixed;

            EditorGUI.BeginChangeCheck();

            gradient = EditorGUILayout.GradientField(LabelText.LightRamp, gradient, true);

            if (!EditorGUI.EndChangeCheck())
            {
                return;
            }

            var newCount = Math.Min(gradient.colorKeys.Length, RampMax);

            for (var i = 0; i < newCount; i++)
            {
                _cellProperties.LightRampColors[i].colorValue = gradient.colorKeys[i].color;
                _cellProperties.LightRampValues[i].floatValue = gradient.colorKeys[i].time;
            }

            _cellProperties.LightRampSize.floatValue = Mathf.Round(newCount);
        }
コード例 #30
0
ファイル: EditorUtils.cs プロジェクト: Assertores/BugInALoop
        public static bool GradientField(ref Gradient curValue, string label, params GUILayoutOption[] guiLayout)
        {
            Gradient newValue = new Gradient
            {
                colorKeys = curValue.colorKeys,
                alphaKeys = curValue.alphaKeys,
            };

            BeginIndentSpaces();
            newValue = EditorGUILayout.GradientField(label, newValue, guiLayout);
            EndIndentSpaces();
            FinishedElementDrawingCall();
            if (!newValue.Equals(curValue))
            {
                ShouldBeDirty();
                curValue = newValue;

                return(true);
            }

            return(false);
        }