public void Awake() { lock (_lock) { if (_instance == null) { // singleton instance _instance = this; if (_mainThread == null || !_mainThread.Equals(Thread.CurrentThread)) { _mainThread = Thread.CurrentThread; } //initialize the logger TraceListener tracelistener = new UnityDebugTraceListener("UnityDebug"); AWSConfigs.AddTraceListener("Amazon", tracelistener); // Associate the main thread dispatcher _instance.gameObject.AddComponent <UnityMainThreadDispatcher>(); // add callback for Editor Mode change #if UNITY_EDITOR IsEditorPlaying = EditorApplication.isPlaying; EditorApplication.playmodeStateChanged += this.HandleEditorPlayModeChange; #endif AmazonHookedPlatformInfo.Instance.Init(); } else { if (this != _instance) { #if UNITY_EDITOR DestroyImmediate(this.gameObject); #else Destroy(this.gameObject); #endif } } } }
public void Awake() { lock (_lock) { if (_instance == null) { _instance = this; if (_mainThread == null || !_mainThread.Equals(Thread.CurrentThread)) { _mainThread = Thread.CurrentThread; } AmazonHookedPlatformInfo.Instance.Init(); Object.DontDestroyOnLoad(this); TraceListener listener = new UnityDebugTraceListener("UnityDebug"); AWSConfigs.AddTraceListener("Amazon", listener); _instance.get_gameObject().AddComponent <UnityMainThreadDispatcher>(); } else if (this != _instance) { Object.DestroyObject(this); } } }
public void Awake() { lock (_lock) { if (_instance == null) { // singleton instance _instance = this; if (_mainThread == null || !_mainThread.Equals(Thread.CurrentThread)) { _mainThread = Thread.CurrentThread; } AmazonHookedPlatformInfo.Instance.Init(); // preventing the instance from getting destroyed between scenes DontDestroyOnLoad(this); //initialize the logger TraceListener tracelistener = new UnityDebugTraceListener("UnityDebug"); AWSConfigs.AddTraceListener("Amazon", tracelistener); // Associate the main thread dispatcher _instance.gameObject.AddComponent <UnityMainThreadDispatcher>(); } else { if (this != _instance) { //destroy the new instance DestroyObject(this); } } } }