# ActionComponent

ActionComponent can be written in a C# script.

## How to create

1. Click the “+” button in the Project window.
2. Select Logic Toolkit > Scripts > Action 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.ActionComponent`.
- Apply `System.SerializableAttribute` to the type.
- Implement `protected override void OnAction()` 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 ActionExample : ActionComponent
    {
        // OnAction is called when the node is executed.
        protected override void OnAction()
        {
            Debug.Log("Hello, world!");
        }
    }

When executed, this example prints `Hello, world!` to the Console.

In addition, a script called Debug.Log is already included as a similar function.