Example #1
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        SlopeGen script = (SlopeGen)target;

        if (GUILayout.Button("Save points"))
        {
            Vector2Array points = new Vector2Array()
            {
                array = script.points
            };

            StreamWriter writer = new StreamWriter(getFileSavePath, false);
            writer.Write(JsonUtility.ToJson(points));
            writer.Close();
            Debug.Log("Saved new points");
        }

        if (GUILayout.Button("Load points"))
        {
            StreamReader reader = new StreamReader(getFileSavePath);
            script.points = JsonUtility.FromJson <Vector2Array>(reader.ReadToEnd()).array;
            reader.Close();
            Debug.Log("Loaded new points");
        }
    }
Example #2
0
    void Update()
    {
        if (oldPos == transform.localPosition)
        {
            return;
        }

        SlopeGen slope = transform.parent.GetComponent <SlopeGen>();

        int index = int.Parse(name.Split('#')[1]);

        slope.points[index] = transform.localPosition;
        slope.Generate(2000);

        oldPos = transform.localPosition;
    }