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();
    }
Ejemplo n.º 2
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        CustomEditorHelpers.DrawHeader("Noise settings");

        EditorGUI.BeginProperty(position, label, property);

        var strengthProperty       = property.FindPropertyRelative("Strength");
        var baseRoughtnessProperty = property.FindPropertyRelative("BaseRoughness");
        var roughnessProperty      = property.FindPropertyRelative("Roughness");
        var persistenceProperty    = property.FindPropertyRelative("Persistence");
        var layersProperty         = property.FindPropertyRelative("Layers");
        var minHeightProperty      = property.FindPropertyRelative("MinHeight");

        EditorGUI.BeginChangeCheck();

        var strenghtValue       = EditorGUILayout.Slider("Strenght", strengthProperty.floatValue, 0, 1);
        var baseRoughtnessValue = EditorGUILayout.Slider("Base roughtness", baseRoughtnessProperty.floatValue, 0, 5);
        var roughtnessValue     = EditorGUILayout.Slider("Roughtness", roughnessProperty.floatValue, 0, 5);
        var persistenceValue    = EditorGUILayout.Slider("Persistence", persistenceProperty.floatValue, 0, 1);
        var layersValue         = (int)EditorGUILayout.Slider("Layers", layersProperty.intValue, 1, 8);
        var minHeightValue      = EditorGUILayout.Slider("MinHeight", minHeightProperty.floatValue, 0, 5);


        if (EditorGUI.EndChangeCheck())
        {
            strengthProperty.floatValue       = strenghtValue;
            baseRoughtnessProperty.floatValue = baseRoughtnessValue;
            roughnessProperty.floatValue      = roughtnessValue;
            persistenceProperty.floatValue    = persistenceValue;
            layersProperty.intValue           = layersValue;
            minHeightProperty.floatValue      = minHeightValue;
        }

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

        EditorGUI.EndProperty();
    }