1. Home
  2. Docs
  3. Factory Pipeline
  4. Runtime API

Runtime API

To use the Broccoli’s run-time API add the following namespaces to your script:

static TreeFactory TreeFactory.GetFactory ()

The first step to generate a tree at run-time is to get a TreeFactory object. This factory will load and use a pipeline to spawn trees on your scene. It is recommended to get a factory per pipeline on the scene to avoid having to load a new pipeline everytime a different product is required.

Pipeline TreeFactory.LoadPipeline (string pathToResource)

After getting a tree factory it is needed to load it with a valid pipeline. In order to have access to a pipeline asset file it should be placed inside a Resources folder. Take in account that the pathToResource parameter should comply with Unity’s resources format, for example a file at Assets/Resources/MyPipelines/myTreePipeline.asset becomes MyPipelines/myTreePipeline. If no pipeline could be loaded the method returns null.

bool Pipeline.IsValid ()

Checks if a pipeline is valid to generate a tree.

GameObject TreeFactory.Spawn ()
GameObject TreeFactory.Spawn (int seed)

Given a valid pipeline loaded to a tree factory, this method produces  a GameObject based on the pipeline instructions. A seed can be used as a parameter to skip randomization every time spawn is called.

Was this article helpful to you? Yes No

How can we help?