public WebSocket(string address) { if (WebSocketReceiver.instance == null) { WebSocketReceiver.AutoCreateInstance(); } this.address = address; }
public static void AutoCreateInstance() { GameObject go = GameObject.Find("/[WebSocketReceiver]"); if (go == null) { go = new GameObject("[WebSocketReceiver]"); } if (go.GetComponent <WebSocketReceiver>() == null) { go.AddComponent <WebSocketReceiver>(); } instance = go.GetComponent <WebSocketReceiver>(); }
void Awake() { DontDestroyOnLoad(gameObject); instance = this; }