private static XDocument LoadConfigFromResource() { XDocument xDoc = null; TextAsset awsEndpoints = null; Action action = () => { awsEndpoints = Resources.Load(CONFIG_FILE) as TextAsset; using (Stream stream = new MemoryStream(awsEndpoints.bytes)) { using (StreamReader reader = new StreamReader(stream)) { xDoc = XDocument.Load(reader); } } }; if (UnityInitializer.IsMainThread()) { action(); } else { ManualResetEvent e = new ManualResetEvent(false); UnityRequestQueue.Instance.ExecuteOnMainThread(() => { action(); e.Set(); }); e.WaitOne(); } return(xDoc); }
private static XDocument LoadConfigFromResource() { XDocument xDoc = null; TextAsset awsConfig = null; Action action = delegate { awsConfig = (Resources.Load("awsconfig") as TextAsset); if (awsConfig != null && awsConfig.get_bytes().Count() > 0) { using (Stream stream = new MemoryStream(awsConfig.get_bytes())) { using (StreamReader textReader = new StreamReader(stream)) { xDoc = XDocument.Load(textReader); } } } }; if (UnityInitializer.IsMainThread()) { action(); } else { ManualResetEvent e = new ManualResetEvent(initialState: false); UnityRequestQueue.Instance.ExecuteOnMainThread(delegate { action(); e.Set(); }); e.WaitOne(); } return(xDoc); }
public void Awake() { lock (_lock) { if (_instance == null) { // singleton instance _instance = this; if (_mainThread == null || !_mainThread.Equals(Thread.CurrentThread)) { _mainThread = Thread.CurrentThread; } // 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>(); // 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) { // singleton instance _instance = this; if (_mainThread == null || !_mainThread.Equals(Thread.CurrentThread)) _mainThread = Thread.CurrentThread; // 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>(); // 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 } } } }
static void LoadEndpointDefinitionsFromEmbeddedResource() { Action action = () => { TextAsset awsEndpoints = Resources.Load(REGIONS_FILE) as TextAsset; using (Stream stream = new MemoryStream(awsEndpoints.bytes)) { using (StreamReader reader = new StreamReader(stream)) { ReadEndpointFile(stream); } } awsEndpoints = Resources.Load(REGIONS_CUSTOMIZATIONS_FILE) as TextAsset; using (Stream stream = new MemoryStream(awsEndpoints.bytes)) { using (StreamReader reader = new StreamReader(stream)) { ReadEndpointFile(stream); } } }; if (UnityInitializer.IsMainThread()) { action(); } else { ManualResetEvent e = new ManualResetEvent(false); UnityRequestQueue.Instance.ExecuteOnMainThread(() => { action(); e.Set(); }); e.WaitOne(); } }
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); } } } }
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); } } } }