Skip to content

Instantly share code, notes, and snippets.

@kyubuns
Created November 20, 2017 06:21
Show Gist options
  • Save kyubuns/d0609398e71e16bb87a5451c72963391 to your computer and use it in GitHub Desktop.
Save kyubuns/d0609398e71e16bb87a5451c72963391 to your computer and use it in GitHub Desktop.
using System.Threading.Tasks;
using UniRx;
using UnityEngine;
public class Sample1 : MonoBehaviour
{
public async Task Start()
{
var input = await MessageBroker.Default.Receive<Hoge>().First();
Debug.Log($"Result: {input.Value}");
}
public void Update()
{
if (Input.GetKeyDown(KeyCode.A))
{
MessageBroker.Default.Publish(new Hoge(123));
}
}
}
public class Hoge
{
public Hoge(int value)
{
Value = value;
}
public int Value { get; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment