Exemplo n.º 1
0
        private static void Initialize()
        {
            var context = SynchronizationContext.Current;

            if (context == null)
            {
                // Create custom SynchronizationContext for the main thread.
                context = new Helpers.MainThreadSynchronizationContext();
                SynchronizationContext.SetSynchronizationContext(context);
            }

            // Set main thread context as default for all continuations. This saves allocations in many cases.
            AsyncResult.DefaultSynchronizationContext = context;

            // Create helper GameObject
            _go = new GameObject("UnityFx.Async")
            {
                hideFlags = HideFlags.HideAndDontSave
            };

            GameObject.DontDestroyOnLoad(_go);

            // Initialize library components.
            AsyncUtility.Initialize(_go, context);
            AsyncWww.Initialize(_go, context);
        }
Exemplo n.º 2
0
        private static void Initialize()
        {
            var context = SynchronizationContext.Current;

            if (context == null)
            {
                // Create custom SynchronizationContext for the main thread.
                context = new Helpers.MainThreadSynchronizationContext();
                SynchronizationContext.SetSynchronizationContext(context);
            }

            // Save the main thread context for future use.
            _mainThreadContext = context;

            // Set main thread context as default for all continuations. This saves allocations in many cases.
            AsyncResult.DefaultSynchronizationContext = context;

            // Initialize library components.
            _go            = new GameObject(RootGoName);
            _rootBehaviour = _go.AddComponent <AsyncRootBehaviour>();
            GameObject.DontDestroyOnLoad(_go);
        }