A singleton instance of which will initialize the Main thread dispatcher & logger. This class is linked to the AWSPrefab so that user can make any configuration changes and instance will be included in every scene via the prefab.
상속: UnityEngine.MonoBehaviour
예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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
                    }
                }
            }
        }
예제 #4
0
        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
                    }
                }

            }
        }
예제 #5
0
        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();
            }
        }
예제 #6
0
 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);
         }
     }
 }
예제 #7
0
        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);
                    }
                }

            }
        }
예제 #8
0
        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);
                    }
                }
            }
        }