Learn how to start a schematic in your code.
You can start a schematic in your custom scripts without having to use a machine component, you just need the schematic asset.
When dealing with schematics, you’ll need to use the schematic namespace:
Before a schematic can be started, you need to create it using a schematic asset.
You can e.g. add it as a field in your component.
Use this code to load the schematic asset into an actual runtime schematic.
You can either start the schematic with or without priority through one of the PlaySchematic functions.
Let’s take a look at the function to start without priority first:
A call of this function can look like this.
Starting a schematic with priority is also done through the PlaySchematic function, using one additional parameter (1st parameter):
The rest of the parameters are the same as using the non-priority start function.
There are 2 ways to get notified by a schematic when it finished execution.
Implement the ISchematicStarter interface in your class. The interface will add 1 function to the class.
An example implementation in a component can look like this.
The function will be called with the instance of the schematic that finished execution as a parameter.
Registering a parameterless function using the Notify function of the schematic, e.g. when the function is added to the same class the call is made from:
The registered function would look like this:
The functions added via Notify will be called before the ISchematicStarter interface. You should add the function via Notify before starting the schematic, in case the schematic finishes immediately (e.g. due to no wait time in nodes being used).
© 2015 Gaming is Love e.U.
Disclosure: This site may contain affiliate links, which means I may receive a commission if you click a link and purchase something that I have recommended. While clicking these links won’t cost you any money, they will help me fund my development projects while recommending great assets!