Skip to content

Instantly share code, notes, and snippets.

@Santarh
Created November 30, 2017 16:40
Show Gist options
  • Save Santarh/7de86f9a354ee977c2f05de5917b1a4e to your computer and use it in GitHub Desktop.
Save Santarh/7de86f9a354ee977c2f05de5917b1a4e to your computer and use it in GitHub Desktop.
using UnityEngine;
public class Foo
{
private readonly int _hoge;
public Foo(GameObject target, int hoge)
{
_hoge = hoge;
target.AddComponent<FooBehaviour>().Init(this);
}
private class FooBehaviour : MonoBehaviour
{
private Foo _self;
public void Init(Foo self)
{
_self = self;
}
private void Update()
{
Debug.Log(_self._hoge);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment