I'm getting some errors from this script. Is this the correct way to start a schematic from script?
using UnityEngine;
using Makinom;

public class test : MonoBehaviour
{
public MakinomSchematicAsset schematicAsset; //define schematic

// Start is called before the first frame update
void Start()
{
Schematic schematic = new Schematic(this.schematicAsset); //load schematic
}

// Update is called once per frame
void Update()
{
schematic.PlaySchematic(null, machineObject, startObject, false, MachineUpdateType.Update); //execute schematic
}
}

image
Post edited by FreedTerror on
  • Generally, yes, but you're creating the schematic in the Start function as a local variable for that function, i.e. it's not accessible in the Update function.

    Also, you need to add the schematic namespace:
    using Makinom.Schematics;
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Is this correct?
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using Makinom;
    using Makinom.Schematics;

    public class test : MonoBehaviour
    {
    public MakinomSchematicAsset schematicAsset; //define schematic

    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
    Schematic schematic = new Schematic(this.schematicAsset); //load schematic
    schematic.PlaySchematic(null, machineObject, startObject, false, MachineUpdateType.Update); //execute schematic
    }
    }

    only getting these errors now
    image
  • Well, since you don't have these 2 anywhere, they'd naturally throw errors. You can replace them with this.gameObject instead, to use the component's game object as machine/starting object.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.