Search Unity

Setting Tree parameters at runtime via script

Discussion in 'Scripting' started by Theoriz, Oct 23, 2019.

  1. Theoriz

    Theoriz

    Joined:
    Jun 7, 2017
    Posts:
    1
    Hello,

    I'm trying to control the parameters of a tree created with Tree tool at runtime using a script. I would like for example to adjust the length of each branch group at runtime to simulate the growth of the tree.

    I found that the tree editor expose those parameters from its TreeEditor.TreeData object which contains the tree information, however looking at the parameters of the branchGroups in this object, there is no Length parameter. Furthermore if I modify one of these parameters via scripting, the editor value is updated but the tree mesh is not (there is an UpdateMesh function in the branchGroup but I have no idea what are the expected parameters of this function).
    I also tried using an animator to animate those parameters but the Tree component does not appear in the animation window...

    So my three questions are :
    1. What is the proper way to change a tree parameter from script at runtime and then update the mesh ?
    2. How can I access the Length parameter of a branch group via script ?
    3. Is there a way to animate the parameters of a Tree with an animator ?

    Thanks for any help !