need help with tree scripting

hello, im searching on how to change tree editor settings via script for about a week now and i that i found was that it is possible and the unity documentation about it,but the problem is : unity documentation about tree’s data only says “tree data”.

so im looking for a example or someone who knows what i can get from the data and how, im sure this will help a lot of people cause everywhere i look there are tons of questions about it and no answers, any example or information is gratelly appreciated!

regards

you need to look at TreeEditor.TreeData.

the following will display some of the variables…

it should be enough for you to get started - just place a tree prefab in TreeTestObject.

using UnityEngine;

public class TreeTest : MonoBehaviour
{
    public Tree TestTreeObject;

    public void Awake()
    {
        if (TestTreeObject != null)
        {
            Debug.Log(TestTreeObject.name);

            var treeData = TestTreeObject.data as TreeEditor.TreeData;

            if (treeData != null)
            {
                var root = treeData.root;

                Debug.Log(string.Format("unique ID = {0}", root.uniqueID));
                Debug.Log(string.Format("seed = {0}", root.seed));
                Debug.Log(string.Format("distribution frequency = {0}", root.distributionFrequency));

                var branchGroups = treeData.branchGroups;

                Debug.Log(string.Format("{0} branch groups", branchGroups.Length));
            }
        }
    }
}

Hey @gjf (or anyone else) I’m also trying to access the scriptable tree object but getting the error, “‘TreeEditor’ could not be found” error as well. Any idea how to access the object from Unity 2018?