A class in Root.Township, Alta.Woodcutting.
Asset that records a tree's full shape (each trunk or branch piece, how they connect, and attachments like leaves or fruit) so it can be rebuilt exactly, at run time or in the editor.
Constructors
| Member | What it is |
|---|
PresetTree() | Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets. |
Fields
4 private and internal fields
| Member | What it is |
|---|
private TreeSize size | Backing field for Size. |
private TreeSpecies[] species | Backing field for Species. The editor uses the first one. |
private List<PresetTree.Step> steps | The tree's pieces in breadth-first order; each step lists its piece prefab, rotation, attachments and child steps. |
private WoodcutTree workingWithTree | Tree set by SaveFrom, captured into steps on the next serialize. |
Properties
| Member | What it is |
|---|
TreeSize Size { get; } | The tree size this preset is for. |
TreeSpecies[] Species { get; } | Species this preset can be used with. |
Methods
| Member | What it is |
|---|
void GenerateEditorTreeOnExisting(WoodcutTree tree) | Editor: builds the recorded pieces onto a tree in the scene, using the first species. |
WoodcutTree GenerateRunTimeTree(INetworkScene scene, NetworkPrefab treePrefab, TreeSpecies species, Transform parent, Vector3 localPosition, Quaternion localRotation, NetworkEntity parentEntity) | Server: spawns a tree prefab of a species and places it under a parent entity, saved as its child. |
void GenerateRunTimeTreeOnExisting(WoodcutTree tree) | Server: builds the recorded pieces onto an existing tree entity and initializes it. |
WoodcutTree GenerateRunTimeTreeWithoutParent(INetworkScene scene, NetworkPrefab treePrefab, TreeSpecies species, Vector3 position, Quaternion rotation, Chunk chunk) | Server: spawns a tree prefab of a species at a world position in a chunk. |
void SaveFrom(WoodcutTree tree) | Marks a tree to record. Its shape is written into the asset when Unity next serializes it. |
5 private and internal methods
| Member | What it is |
|---|
private void HandleEditorStep(INetworkScene scene, WoodcutTree tree, PresetTree.Step step, WoodcutConnection parent) | Editor: instantiates one step's piece and attachments, then recurses into its child connections. |
private void HandleStep(WoodcutTree tree, PresetTree.Step step, WoodcutConnection parent) | Server: spawns one step's tree piece and attachments onto the tree, then recurses into its child connections by hash. |
private void UnityEngine.ISerializationCallbackReceiver.OnAfterDeserialize() | Explicit Unity serialization callback. Empty. |
private void UnityEngine.ISerializationCallbackReceiver.OnBeforeSerialize() | Explicit Unity serialization callback: after SaveFrom, walks that tree and rewrites steps from it. |
private WoodcutTree SpawnAndInitWoodcutTree(INetworkScene scene, NetworkPrefab treePrefab, TreeSpecies species) | Spawns the tree prefab, sets its species and this preset, and initializes it as server. |
Used in
Members of other types that take, return or hold a PresetTree: