Unity/UniRx/Subject
サンプル
using UniRx;
Subject<string> subject = new Subject<string>();
// イベント登録
subject.Subscribe(message => Debug.Log("msg1:" + message));
// イベント発行
subject.OnNext("hello");
ログ
msg1:hello
参考:https://qiita.com/toRisouP/items/2f1643e344c741dd94f8
UniRxを使わない場合
このように書く
using System;
Action<string> OnMsg = delegate (string msg) { };
OnMsg += (msg) => {
Debug.Log("msg1:" + msg);
};
OnMsg("hello");
参考:https://sunagimo-app.hatenablog.com/entry/2019/03/14/032357