Esempio n. 1
0
 internal WaitData(Type presentType, LoadRuleData rule, object openArg, Action callback)
 {
     this.presentType = presentType;
     this.rule        = rule;
     this.openArg     = openArg;
     this.callback    = callback;
 }
Esempio n. 2
0
            void OpenPresentWait(Type presentType, LoadRuleData rule, object openArg, Action callback)
            {
                if (null != this.wait)
                {
                    Debug.LogError(string.Format("PRESENT<{0}={1:X8}>:NEXT_DUPLICATED_EXCEPTION#1:{2}, RULE:{3}, ARG:{4}, CB{5}, WAIT:{6}, CURRENT:{7}",
                                                 this.CurrentPresentName,
                                                 (uint)this.CurrentPresentHashCode,
                                                 null != presentType ? presentType.Name : "null",
                                                 rule,
                                                 openArg,
                                                 callback,
                                                 this.wait,
                                                 this.presentType));
                    return;
                }

                this.wait = new WaitData(presentType, rule, openArg, callback);
            }
Esempio n. 3
0
            internal void OpenNextPresent(Type presentType, LoadRuleData rule, object openArg, Action callback)
            {
                if (null == rule)
                {
                    rule = Present.DefaultLoadRule;
                }

#if LOG_DEBUG
                Debug.Log(string.Format("PRESENT<{0}={1:X8}>:NEXT:{2}, RULE:{3}, ARG:{4}, CB:{5}, STACK_TRACE:\n{6}",
                                        this.CurrentPresentName,
                                        (uint)this.CurrentPresentHashCode,
                                        null != presentType ? presentType.Name : "null",
                                        rule,
                                        openArg,
                                        callback,
                                        new System.Diagnostics.StackTrace(true).ToString()));
#endif// LOG_DEBUG
#if LOG_MEMORY
                var stateOfPresent = null != this.loadedPresent ? this.loadedPresent.GetState() : -1;
                Debug.Log(string.Format("APP:{0}, {1}, {2}",
                                        DebugImpl.CreateUptimeChunk(),
                                        DebugImpl.CreatePresentChunk("AT", presentType, -1),
                                        DebugImpl.CreatePresentChunk("EVENT:SET_PRESENT_PREV", this.presentType, stateOfPresent)));
#endif// LOG_MEMORY

                this.ClosePresent(presentType);

                if (null != this.asyncOperFakeOpenForGarbageCollect || null != this.asyncOper || this.fastOpenWait)
                {
#if LOG_DEBUG
                    Debug.Log(string.Format("PRESENT<{0}={1:X8}>:NEXT_DUPLICATED:{2}",
                                            this.CurrentPresentName,
                                            (uint)this.CurrentPresentHashCode,
                                            null != presentType ? presentType.Name : "null"));
#endif// LOG_DEBUG
                    this.OpenPresentWait(presentType, rule, openArg, callback);
                    return;
                }
                else if (null != this.wait)
                {
                    Debug.LogError(string.Format("PRESENT<{0}={1:X8}>:NEXT_DUPLICATED_EXCEPTION#2:{2}, RULE:{3}, ARG:{4}, CB{5}, WAIT:{6}, CURRENT:{7}",
                                                 this.CurrentPresentName,
                                                 (uint)this.CurrentPresentHashCode,
                                                 null != presentType ? presentType.Name : "null",
                                                 rule,
                                                 openArg,
                                                 callback,
                                                 this.wait,
                                                 this.presentType));
                    return;
                }

                this.presentTypePrev = this.presentType;
                this.presentType     = presentType;

                this.openArg = openArg;

                this.openCallback = callback;
                this.isChanging   = true;

                Preference.Save();
                this.preloadPresent = (Present)Activator.CreateInstance(this.presentType);
#if LOG_DEBUG
                Debug.Log(string.Format("PRESENT<{0}={1:X8}>:CREATE_INSTANCE:<{2}={3:X8}>",
                                        this.CurrentPresentName,
                                        (uint)this.CurrentPresentHashCode,
                                        null != this.preloadPresent ? this.preloadPresent.GetType().Name : "null",
                                        null != this.preloadPresent ? (uint)this.preloadPresent.GetHashCode() : 0u));
#endif// LOG_DEBUG
                try
                {
                    this.preloadPresent.OnPreloading();
                }
                catch (Exception e)
                {
                    Debug.LogError(string.Format("PRESENT<{0}={1:X8}>:LOAD_EXCEPT:{2}",
                                                 this.CurrentPresentName,
                                                 (uint)this.CurrentPresentHashCode,
                                                 e));
                }

                switch (rule.Rule)
                {
                case LoadRule.FlushGarbage:
                    this.asyncOperFakeOpenForGarbageCollect = SceneManager.LoadSceneAsync("Next");
                    break;

                case LoadRule.Direct:
                    if (this.preloadPresent.DoOpen)
                    {
                        this.asyncOper = SceneManager.LoadSceneAsync(this.presentType.Name);
                    }
                    else
                    {
                        this.fastOpenWait = true;
                    }
                    break;

                case LoadRule.PreloadedScene:
                    this.asyncOper = rule.Preloaded;
                    break;
                }
            }
Esempio n. 4
0
 public static void OpenNextPresent(Type presentType, LoadRuleData rule = null, object openArg = null, Action callback = null)
 {
     Present.Singleton.OpenNextPresent(presentType, rule, openArg, callback);
 }