EvaluateComponent

EvaluateComponent can be written in a C# script.

How to create

  1. Click the “+” button in the Project window.
  2. Select Logic Toolkit > Scripts > Evaluate Component C# Script from the menu.
  3. Enter the script name and confirm with Enter.

How to write a script

  • Create a class that inherits from LogicToolkit.EvaluateComponent.
  • Apply System.SerializableAttribute to the type.
  • Implement protected override bool OnEvaluate() and write the processing at runtime.

Code example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using LogicToolkit;

[System.Serializable]
public class EvaluateExample : EvaluateComponent
{
    // OnEvaluate() is called when performing an evaluation
    protected override bool OnEvaluate()
    {
        return Input.GetKeyDown(KeyCode.Space);
    }
}

In this example, when executed, it will check whether the space key has been pressed and return the result.

A similar script can be created by selecting Input.GetKeyDown(KeyCode) when generating the script.