#Help With Changing values of a script.

1 messages · Page 1 of 1 (latest)

haughty sedge
random rampart
# haughty sedge set the seed in some script, have a Start() method, or Awake() <https://docs.un...

Sorry for such a late reply, but where would I put this in my script.

using UnityEngine;
using System.Collections;

[CreateAssetMenu()]
public class NoiseData : UpdatableData {

    public Noise.NormalizeMode normalizeMode;

    public float noiseScale;

    public int octaves;
    [Range(0,1)]
    public float persistance;
    public float lacunarity;

    public int seed;
    public Vector2 offset;

    #if UNITY_EDITOR

    protected override void OnValidate() {
        if (lacunarity < 1) {
            lacunarity = 1;
        }
        if (octaves < 0) {
            octaves = 0;
        }

        base.OnValidate ();
    }
    #endif

}

Thanks once again.

haughty sedge
# random rampart Sorry for such a late reply, but where would I put this in my script. ```cs usin...

what script does the generation of the noise map?
you could copy an existing noise Data in a script by calling Instantiate and passing the NoiseData instance I suppose
https://docs.unity3d.com/ScriptReference/Object.Instantiate.html
then on the copy, change seed value, and then call the environment creation method with that noiseData copy

do that maybe in some MonoBehaviour in Awake or Start
maybe the creation method is in a separate script or in the parent object in OnValidate?

the reason for why i mention a copy (you don't have to make the copy) is that since a scriptable object is an asset, if you change the seed in the original object, and leave playmode, it will keep the changed seed