Starting a Schematic

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:

Loading from a Schematic Asset #

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.

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:

  • ISchematicStarter starter
    The ISchematicStarter interface used as an argument will be notified by the schematic when it finished playing.
    Implement the ISchematicStarter interface in a class (e.g. the class starting the schematic), or just use null as an argument to not get notified.
    You can also get notified by a schematic when it finished by adding a parameterless function to the Notify function of the schematic.
  • object machineObject
    The object that will be used as machine object in the schematic, usually you’ll use a game object.
  • object startingObject
    The object that will be used as starting object in the schematic, usually you’ll use a game object.
  • 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.
  • int inputID
    The input ID that will be used by this schematic.
    You can use Maki.Control.InputID to pass on the current global input ID of Makinom.

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 (1st 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.

Getting notified by a finished schematic #

There are 2 ways to get notified by a schematic when it finished execution.

The ISchematicStarter Interface #

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 Notify function #

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).