void OnDisable() { PlayerPrefs.SetString("client_id", localClient.id); PlayerPrefs.SetString("client_name", localClient.name); StopAllCoroutines(); pubnub = null; }
void OnEnable() { var id = PlayerPrefs.GetString("client_id", System.Guid.NewGuid().ToString()); var name = player_name; localClient = new Client(id, name, Color.white); //windowRect = new Rect(20.0F, 20.0F, 600.0F, 440.0F); messages = new List <Message>(); clients = new Dictionary <string, Client>(); currentChat = ""; scrollPosition = new Vector2(0, int.MaxValue); pubnub = ScriptableObject.CreateInstance <UnityPubNub>(); var url = string.IsNullOrEmpty(Application.srcValue) ? "localhost" : Application.absoluteURL; pubnub.Init(string.Format("unity.pubnub.{0}", PubNub.Tools.MD5(url))); StartCoroutine(Chat()); }