SendMessageByName


With a Utage scenario, you do a SendMessage to the Unity object with the specified name.
Can be used even more easily than the SendMessage command.

Sample

Reference

Command Description Arg1 Arg2 Arg3 Arg4 Arg5 Arg6
SendMessageByName SendMessage to the GameObject with the specified name GameObject name Optional argument Optional argument Optional argument Optional argument Optional argument

Sample for Receiving a SendMessageByName

Create an object with the name specified in Arg1 on Unity, and then write a component for receiving messages.

The contents of the cells entered in Excel, such as those from Arg2 to Text, can be obtained with command.ParseCellOptional<>, allowing you to pass arguments in a flexible way.

using UnityEngine;
using Utage;
using System.Collections;

/// <summary>
/// ADV用SendMessageByNameコマンドから送られたメッセージを受け取る処理のサンプル
/// </summary>
[AddComponentMenu("Utage/ADV/Examples/SendMessageByName")]
public class SampleSendMessageByName : MonoBehaviour
{
    //Testという処理を呼ぶ。引数にはAdvCommandSendMessageByNameを持つ
    void Test(AdvCommandSendMessageByName command)
    {
        Debug.Log("SendMessageByName");
    }

    //引数を使った例
    void TestArg(AdvCommandSendMessageByName command)
    {
        Debug.Log(command.ParseCellOptional<string>(AdvColumnName.Arg3, "arg3"));

'7d

    //引数を使った例
    void TestWait(AdvCommandSendMessageByName command)
    {
        StartCoroutine(CoWait(command));
    }

    //command.IsWaitでコマンド終了待ちも切り替えられる
    IEnumerator CoWait(AdvCommandSendMessageByName command)
    {
        command.IsWait = true;

        float time = command.ParseCellOptional<float>(AdvColumnName.Arg3, 0);
        while (true)
        {
            Debug.Log(time);
            time -= Time.deltaTime;
            if (time <= 0) break;
            yield return 0;
        }
        command.IsWait = false;
    }
}