Learn starting a schematic in your code.

You can start a schematic in your custom scripts without having to use a machine component.

Loading from a Schematic Asset

Before a schematic can be started, you need to load it from 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 schematic.

Starting a schematic

You can either start the schematic with or without priority through one of the PlaySchematic functions.

Non-Priority Start

Let’s take a look at the function to start without priority first:

  • IExecutionStarter starter
    The IExecutionStarter interface used as an argument will be notified by the schematic when it finished playing.
    Implement the IExecutionStarter interface in a class (e.g. the class starting the schematic), or just use null as an argument to not get notified.
  • GameObject machineObject
    The game object that will be used as machine object in the schematic.
  • GameObject startingObject
    The game object that will be used as starting object in the schematic.
  • bool isBlocking
    Use true if this is a blocking schematic, otherwise false.
    Only one blocking schematic can be executed at a time.
  • MachineUpdateType updateType
    The MachineUpdateType enum handles which update function (UpdateLateUpdate or FixedUpdate) will be used by the schematic.

A call of this function can look like this.

Priority Start

Starting a schematic with priority is also done through the PlaySchematic function, using one additional parameter:

  • int priority
    The priority of the schematic.
    The highest priority number will be executed first.

The rest of the parameters are the same as using the non-priority start function.

A call of this function can look like this.

The IExecutionStarter Interface

If you want to be notified by a schematic when it finished playing, implement the IExecutionStarter interface in your class. The interface will add 2 functions and 2 properties to the class.

An example implementation in a component can look like this.