# スクリプト生成

You can generate scripts to access members such as methods and properties.

Just select the member you want to access from the list and it will be created.
You can quickly implement it without having to write each script one by one.

## Condition

The conditions for members to have access are as follows.

- Must be a type defined in the Assembly Definition File or pre-compiled managed DLL
- Must be a public member of a public type
- Must be other than a generic type or method
- `LogicToolkit.IgnoreGeneratorAttribute` is not applied to the type or member

## Supported member access

The supported member access is as follows.

### Get field

Create a script to get the field's value.

Component created

The component created changes depending on the field type.

Type of field | Component created | Description
--- | --- | ---
bool type | EvaluateComponent | Create a script that returns a value as the evaluation result.
delegate type | EventComponent | Create a script that waits for the event to be called. Outputs the argument value received when the event is called from `OutputDataPort`.
UnityEvent type | EventComponent | Create a script that waits for the event to be called. Outputs the argument value received when the event is called from `OutputDataPort`.
Miscellaneous | ActionComponent | Create a script to get the value and output it from `OutputDataPort`.

### Set field

Create a script to set the field's value.

Component created

ActionComponent

### Tween field

Create a script that gradually interpolates the value of a field until it reaches a specified value.
Only tweenable types can be generated.

Component created

TaskComponent

### Get property

Create a script to get the property's value.

Component created

The component created varies depending on the property type.

Property type | Component created | Description
--- | --- | ---
bool type | EvaluateComponent | Create a script that returns a value as the evaluation result.
delegate type | EventComponent | Create a script that waits for the event to be called. Outputs the argument value received when the event is called from `OutputDataPort`.
UnityEvent type | EventComponent | Create a script that waits for the event to be called. Outputs the argument value received when the event is called from `OutputDataPort`.
Miscellaneous | ActionComponent | Create a component that retrieves a value and outputs it from the `OutputDataPort`.

### Set property

Create a script to set the property's value.

Component created

ActionComponent

### Tween property

Create a script that gradually interpolates the value of a property until it reaches a specified value. Only tweenable types can be generated.

Component created

TaskComponent

### Waiting for the event

Create a script that waits for an event to be called.
Outputs the argument value received when the event is called from `OutputDataPort`.

Component created

EventComponent

### Invoke method

Create a script that invokes the method.

Component created

The component created depends on the return type.

Return Type | Component Created | Description
--- | --- | ---
bool type | EvaluateComponent | Create a script that returns the return value as the evaluation result.
Asynchronous (awaitable type or async) method | TaskComponent | Create a script that waits until completion.
AsyncOperation | TaskComponent | Create a script that waits until it completes.
Miscellaneous | ActionComponent | Create a script that invokes the method.

If the method argument is out or ref, the result of the argument will also be output from `OutputDataPort` after execution.

## How to create

You can create a script to access members in the following ways:

### Node/Component selection menu

- Open the graph view node creation menu and component selection menu
- Select the Members tab.
- Search by name of the member you want to access.
- Select the members you want to access.
- (If using the node creation menu, select the type of node to create.)

If you have already generated a script to access the selected member, use the existing script.
If it has not been generated yet, generation processing and compilation will be performed, and after completion, nodes will be created, etc.

Already generated scripts are also displayed in the Scripts tab.

### Logic Script Generator window

You can create multiple scripts in advance in the Logic Script Generator window.

- Select Logic Toolkit > Logic Script Generator from the menu to open the Logic Script Generator window.
- Click the “+” button on the left pane.
- Check the members you want to add from the tree.
- Click the “Add” button in the add menu.
- Return to the Logic Script Generator window and click the “Apply” button at the bottom of the left pane.

For details, see Logic Script Generator Window.

## Important point

Access information for members is managed using type names, member names, etc. If you change or delete members of a generated script later, a compilation error will occur. Open the “Logic Script Generator window” and modify or delete the relevant script.

If you change the type name, the migration will be done automatically by applying MovedFromAttribute.