コード例 #1
0
        public override string GetDefaultSerializedString()
        {
            StrataFractalInput strata = new StrataFractalInput();

            strata.Reset();

            return(ToSerializedString(strata));
        }
コード例 #2
0
 private void DomainWarpSettingsGUI(ref StrataFractalInput strata)
 {
     using (new EditorGUI.DisabledScope(!strata.warpEnabled))
     {
         strata.warpIterations = EditorGUILayout.Slider(Styles.warpIterations, strata.warpIterations, strata.warpIterationsMinMax.x, strata.warpIterationsMinMax.y);
         strata.warpStrength   = EditorGUILayout.Slider(Styles.warpStrength, strata.warpStrength, strata.warpStrengthMinMax.x, strata.warpStrengthMinMax.y);
         strata.warpOffsets    = EditorGUILayout.Vector4Field(Styles.warpOffsets, strata.warpOffsets);
     }
 }
コード例 #3
0
        public override object FromSerializedString(string serializedString)
        {
            if (string.IsNullOrEmpty(serializedString))
            {
                serializedString = GetDefaultSerializedString();
            }

            // TODO(wyatt): do validation/upgrading here

            StrataFractalInput target = JsonUtility.FromJson <StrataFractalInput>(serializedString);

            return(target);
        }
コード例 #4
0
        public override string ToSerializedString(object target)
        {
            if (target == null)
            {
                return(null);
            }

            if (!(target is StrataFractalInput))
            {
                Debug.LogError($"Attempting to serialize an object that is not of type {typeof(StrataFractalInput)}");
                return(null);
            }

            StrataFractalInput strata = (StrataFractalInput)target;

            string serializedString = JsonUtility.ToJson(strata);

            return(serializedString);
        }
コード例 #5
0
        public override string DoGUI(string serializedString)
        {
            if (string.IsNullOrEmpty(serializedString))
            {
                serializedString = GetDefaultSerializedString();
            }

            // deserialize string
            StrataFractalInput strata = (StrataFractalInput)FromSerializedString(serializedString);

            // do gui here
            EditorGUILayout.Space();
            strata.strataOffset = EditorGUILayout.FloatField(Styles.strataOffset, strata.strataOffset);
            strata.strataScale  = EditorGUILayout.FloatField(Styles.strataScale, strata.strataScale);
            EditorGUILayout.Space();
            strata.octaves     = EditorGUILayout.Slider(Styles.octaves, strata.octaves, strata.octavesMinMax.x, strata.octavesMinMax.y);
            strata.amplitude   = EditorGUILayout.Slider(Styles.amplitude, strata.amplitude, strata.amplitudeMinMax.x, strata.amplitudeMinMax.y);
            strata.persistence = EditorGUILayout.Slider(Styles.persistence, strata.persistence, strata.persistenceMinMax.x, strata.persistenceMinMax.y);
            strata.frequency   = EditorGUILayout.Slider(Styles.frequency, strata.frequency, strata.frequencyMinMax.x, strata.frequencyMinMax.y);
            strata.lacunarity  = EditorGUILayout.Slider(Styles.lacunarity, strata.lacunarity, strata.lacunarityMinMax.x, strata.lacunarityMinMax.y);

            bool toggled = strata.warpEnabled;

            strata.warpExpanded = TerrainToolGUIHelper.DrawToggleHeaderFoldout(Styles.domainWarpSettings, strata.warpExpanded, ref toggled);

            if (strata.warpExpanded)
            {
                EditorGUI.indentLevel++;
                {
                    DomainWarpSettingsGUI(ref strata);
                }
                EditorGUI.indentLevel--;
            }

            strata.warpEnabled = toggled;

            return(ToSerializedString(strata));
        }
コード例 #6
0
        public override void SetupMaterial(Material mat, string serializedString)
        {
            if (string.IsNullOrEmpty(serializedString))
            {
                serializedString = GetDefaultSerializedString();
            }

            StrataFractalInput strata = (StrataFractalInput)FromSerializedString(serializedString);

            // set noise domain values
            mat.SetFloat("_StrataOctaves", strata.octaves);
            mat.SetFloat("_StrataAmplitude", strata.amplitude);
            mat.SetFloat("_StrataFrequency", strata.frequency);
            mat.SetFloat("_StrataPersistence", strata.persistence);
            mat.SetFloat("_StrataLacunarity", strata.lacunarity);

            // warp values
            mat.SetFloat("_StrataWarpIterations", strata.warpEnabled ? strata.warpIterations : 0);
            mat.SetFloat("_StrataWarpStrength", strata.warpStrength);
            mat.SetVector("_StrataWarpOffsets", strata.warpOffsets);

            mat.SetFloat("_StrataStrataOffset", strata.strataOffset);
            mat.SetFloat("_StrataStrataScale", strata.strataScale);
        }