コード例 #1
0
        /// <summary> Run library initialization logic. </summary>
        public static CompositionRoot Run()
        {
            const string fatalCategoryName = "Fatal";

            // create default container which should not be exposed outside to avoid Service Locator pattern.
            var container = new Container();

            // create trace to log important messages
            var trace = new UnityLogTrace();

            // utymap requires some files/directories to be precreated.
            InstallationApi.EnsureFileHierarchy(trace);

            // setup RX configuration.
            UnityScheduler.SetDefaultForUnity();

            // subscribe to unhandled exceptions in RX
            MainThreadDispatcher.RegisterUnhandledExceptionCallback(ex => trace.Error(fatalCategoryName, ex, "Unhandled exception"));

            try
            {
                var compositionRoot = BuildCompositionRoot(container, trace);
                SubscribeOnMapData(compositionRoot, trace);
                return(compositionRoot);
            }
            catch (Exception ex)
            {
                trace.Error(fatalCategoryName, ex, "Cannot setup object graph.");
                throw;
            }
        }
コード例 #2
0
ファイル: InitTask.cs プロジェクト: FrostHYH/utymap
        /// <summary> Run library initialization logic. </summary>
        public static CompositionRoot Run(Action <IContainer, IConfigSection> action)
        {
            const string fatalCategoryName = "Fatal";

            // create trace for logging and set its level
            var trace = new UnityLogTrace();

            trace.Level = DefaultTrace.TraceLevel.Debug;

            // utymap requires some files/directories to be precreated.
            InstallationApi.EnsureFileHierarchy(trace);

            // setup RX configuration.
            UnityScheduler.SetDefaultForUnity();

            // subscribe to unhandled exceptions in RX
            MainThreadDispatcher.RegisterUnhandledExceptionCallback(ex => trace.Error(fatalCategoryName, ex, "Unhandled exception"));

            try
            {
                var compositionRoot = BuildCompositionRoot(action, trace);
                SubscribeOnMapData(compositionRoot, trace);
                return(compositionRoot);
            }
            catch (Exception ex)
            {
                trace.Error(fatalCategoryName, ex, "Cannot setup object graph.");
                throw;
            }
        }
    public static SimpleCoroutineAwaiter <T> GetAwaiter <T>(this IEnumerator <T> coroutine)
    {
        var awaiter = new SimpleCoroutineAwaiter <T>();

        UnityScheduler.Run(() => AsyncCoroutineRunner.Instance.StartCoroutine(
                               new CoroutineWrapper <T>(coroutine, awaiter).Run()));
        return(awaiter);
    }
    public static SimpleCoroutineAwaiter <UnityEngine.Object> GetAwaiter(this AssetBundleRequest instruction)
    {
        var awaiter = new SimpleCoroutineAwaiter <UnityEngine.Object>();

        UnityScheduler.Run(() => AsyncCoroutineRunner.Instance.StartCoroutine(
                               InstructionWrappers.AssetBundleRequest(awaiter, instruction)));
        return(awaiter);
    }
    static SimpleCoroutineAwaiter <T> GetAwaiterReturnSelf <T>(T instruction)
    {
        var awaiter = new SimpleCoroutineAwaiter <T>();

        UnityScheduler.Run(() => AsyncCoroutineRunner.Instance.StartCoroutine(
                               InstructionWrappers.ReturnSelf(awaiter, instruction)));
        return(awaiter);
    }
コード例 #6
0
        public void InitializeFramework(ConfigBuilder configBuilder, Action <CompositionRoot> initAction)
        {
            IsInitialized = false;

            // Need to dispose all previously used components as we're going to create new ones.
            if (_container != null)
            {
                _container.Dispose();
            }

            // create default container which should not be exposed outside to avoid Service Locator pattern.
            _container = new Container();

            // create trace to log important messages
            _trace = new DebugConsoleTrace();

            // UtyMap requires some files/directories to be precreated.
            InstallationApi.EnsureFileHierarchy(_trace);

            // Setup RX configuration.
            UnityScheduler.SetDefaultForUnity();

            // subscribe to unhandled exceptions in RX
            MainThreadDispatcher.RegisterUnhandledExceptionCallback(ex =>
                                                                    _trace.Error(FatalCategoryName, ex, "Unhandled exception"));

            try
            {
                var config = configBuilder
                             .SetStringIndex("Index/")
                             .SetSpatialIndex("Index/")
                             .Build();

                // create entry point for utymap functionallity
                _compositionRoot = new CompositionRoot(_container, config)
                                   .RegisterAction((c, _) => c.RegisterInstance <ITrace>(_trace))
                                   .RegisterAction((c, _) => c.Register(Component.For <IPathResolver>().Use <DemoPathResolver>()))
                                   .RegisterAction((c, _) => c.Register(Component.For <IModelBuilder>().Use <DemoModelBuilder>()))
                                   .RegisterAction((c, _) => c.Register(Component.For <INetworkService>().Use <DemoNetworkService>()))
                                   .RegisterAction((c, _) => c.Register(Component.For <CustomizationService>().Use <CustomizationService>()))
                                   .RegisterAction((c, _) => c.Register(Component.For <Stylesheet>().Use <Stylesheet>(@"MapCss/default/default.mapcss")));

                // this is the way to insert custom extensions from outside. You may need to do it for
                // some scenes.
                initAction(_compositionRoot);

                // setup object graph
                _compositionRoot.Setup();

                IsInitialized = true;
            }
            catch (Exception ex)
            {
                _trace.Error(FatalCategoryName, ex, "Cannot setup object graph.");
                throw;
            }
        }
コード例 #7
0
ファイル: ReactUnity.cs プロジェクト: ma-vejsada/core
 void CreateScheduler(Engine engine)
 {
     scheduler = new UnityScheduler();
     engine.SetValue("UnityScheduler", scheduler);
     engine.SetValue("setTimeout", new Func <JsValue, int, int>(scheduler.setTimeout));
     engine.SetValue("setInterval", new Func <JsValue, int, int>(scheduler.setInterval));
     engine.SetValue("clearTimeout", new Action <int>(scheduler.clearTimeout));
     engine.SetValue("clearInterval", new Action <int>(scheduler.clearInterval));
     engine.SetValue("requestAnimationFrame", new Func <JsValue, int>(scheduler.requestAnimationFrame));
     engine.SetValue("cancelAnimationFrame", new Action <int>(scheduler.cancelAnimationFrame));
 }
コード例 #8
0
 void CreateScheduler(Jint.Engine engine)
 {
     scheduler = new UnityScheduler();
     engine.SetValue("UnityScheduler", scheduler);
     engine.Execute("global.setTimeout = function setTimeout(fun, delay) { return UnityScheduler.setTimeout(new Callback(fun), delay); }");
     engine.Execute("global.setInterval = function setInterval(fun, delay) { return UnityScheduler.setInterval(new Callback(fun), delay); }");
     engine.Execute("global.setImmediate = function setImmediate(fun) { return UnityScheduler.setImmediate(new Callback(fun)); }");
     engine.Execute("global.requestAnimationFrame = function requestAnimationFrame(fun) { return UnityScheduler.requestAnimationFrame(new Callback(fun)); }");
     engine.SetValue("clearTimeout", new Action <int?>(scheduler.clearTimeout));
     engine.SetValue("clearInterval", new Action <int?>(scheduler.clearInterval));
     engine.SetValue("clearImmediate", new Action <int?>(scheduler.clearImmediate));
     engine.SetValue("cancelAnimationFrame", new Action <int?>(scheduler.cancelAnimationFrame));
 }
        public void Complete(T result, Exception e)
        {
            Assert(!_isDone);

            _isDone    = true;
            _exception = e;
            _result    = result;

            // Always trigger the continuation on the unity thread when awaiting on unity yield
            // instructions
            if (_continuation != null)
            {
                UnityScheduler.Run(_continuation);
            }
        }
コード例 #10
0
        private void _QueueRoutine(COROUTINE coroutine, IEnumerator routine)
        {
            //if (coroutineData == null)
            {
                if (routine is COROUTINE)
                {
                    routine = CoroutineToRoutine((COROUTINE)routine);
                }
            }
            var cancelToken = GetCancelToken(coroutine);

            if (cancelToken != null)
            {
                if (cancelToken.IsCancellationRequested)
                {
                    SetCoroutineCanceled(coroutine);
                    return;
                }
                //UnityScheduler.StartCoroutine(WaitCancel(coroutine, cancelToken));
            }
            UnityScheduler.StartCoroutine(AsCoroutine(coroutine, routine));
            SetReady(coroutine);
        }
コード例 #11
0
 private static void InitializeInEditor()
 {
     UnityScheduler.InitializeInEditor();
     EditorApplication.update += UnityScheduler.ProcessEditorUpdate;
 }
コード例 #12
0
 private void Update()
 {
     TaskCount = UnityScheduler.UpdateAndGetTaskCount();
 }