コード例 #1
0
        void OnStageSwitched(StageNavigationItem newStage, bool setAsFirstItemAfterMainStage, Analytics.ChangeType changeTypeAnalytics)
        {
            var previousStage = currentItem;

            if (setAsFirstItemAfterMainStage)
            {
                m_NavigationHistory.ClearHistory();
                m_NavigationHistory.AddItem(newStage);
            }
            else
            {
                if (m_NavigationHistory.TrySetToIndexOfItem(newStage))
                {
                    m_NavigationHistory.ClearForwardHistoryAfterCurrentStage();
                }
                else
                {
                    m_NavigationHistory.ClearForwardHistoryAndAddItem(newStage);
                }
            }

            if (stageChanged != null)
            {
                stageChanged(previousStage, newStage);
            }

            m_Analytics.ChangingStageEnded(newStage, changeTypeAnalytics);
        }
コード例 #2
0
        internal static string CreateWindowAndStageIdentifier(string windowGUID, StageNavigationItem stage)
        {
            // Limit guids to prevent long file names on Windows
            string windowID = windowGUID.Substring(0, 6);
            string stageID  = stage.isMainStage ? "mainStage" : AssetDatabase.AssetPathToGUID(stage.prefabAssetPath).Substring(0, 18);

            return(windowID + "-" + stageID);
        }
コード例 #3
0
            public void ChangingStageEnded(StageNavigationItem newStageItem, Analytics.ChangeType changeTypeAnalytics)
            {
                m_EventData.changeType         = changeTypeAnalytics;
                m_EventData.newStage           = GetStageType(newStageItem);
                m_EventData.newBreadcrumbCount = StageNavigationManager.instance.stageHistory.Length;
                m_EventData.autoSaveEnabled    = StageNavigationManager.instance.autoSave;
                var duration = DateTime.UtcNow.Subtract(m_StartedTime);

                UsabilityAnalytics.SendEvent("stageChange", m_StartedTime, duration, true, m_EventData);
            }
コード例 #4
0
        public void ClearForwardHistoryAndAddItem(StageNavigationItem item)
        {
            if (item == currentItem)
            {
                return;
            }

            ClearForwardHistoryAfterCurrentStage();
            AddItem(item);
        }
コード例 #5
0
 static StageType GetStageType(StageNavigationItem item)
 {
     if (item.isMainStage)
     {
         return(StageType.MainStage);
     }
     if (item.isPrefabStage)
     {
         return(StageType.PrefabStage);
     }
     return(StageType.Unknown);
 }
コード例 #6
0
        public StageNavigationItem GetOrCreatePrefabStage(string prefabAssetPath)
        {
            for (int i = 0; i < m_History.Count; i++)
            {
                if (!m_History[i].isMainStage && m_History[i].prefabAssetPath == prefabAssetPath)
                {
                    return(m_History[i]);
                }
            }

            return(StageNavigationItem.CreatePrefabStage(prefabAssetPath));
        }
コード例 #7
0
        public StageNavigationItem GetOrCreateMainStage()
        {
            for (int i = 0; i < m_History.Count; i++)
            {
                if (m_History[i].isMainStage)
                {
                    return(m_History[i]);
                }
            }

            return(StageNavigationItem.CreateMainStage());
        }
コード例 #8
0
            public void ChangingStageStarted(StageNavigationItem previousStageItem)
            {
                m_StartedTime = DateTime.UtcNow;

                m_EventData = new EventData();
                m_EventData.existingStage           = GetStageType(previousStageItem);
                m_EventData.existingBreadcrumbCount = StageNavigationManager.instance.stageHistory.Length;
                if (previousStageItem.prefabStage != null)
                {
                    m_EventData.didUserModify = previousStageItem.prefabStage.analyticsDidUserModify;
                    m_EventData.didUserSave   = previousStageItem.prefabStage.analyticsDidUserSave;
                }
            }
コード例 #9
0
        public bool TrySetToIndexOfItem(StageNavigationItem item)
        {
            for (int i = 0; i < m_History.Count; ++i)
            {
                if (m_History[i] == item)
                {
                    m_CurrentIndex = i;
                    return(true);
                }
            }

            return(false);
        }
コード例 #10
0
        internal bool SwitchToStage(StageNavigationItem newStage, bool setAsFirstItemAfterMainStage, bool setPreviousSelection, Analytics.ChangeType changeTypeAnalytics)
        {
            if (newStage.isPrefabStage && !newStage.prefabAssetExists)
            {
                Debug.LogError("Cannot switch to new stage! Prefab asset does not exist: " + (!string.IsNullOrEmpty(newStage.prefabAssetPath) ? newStage.prefabAssetPath : newStage.prefabAssetGUID));
                {
                    return(false);
                }
            }

            StopAnimationPlaybackAndPreviewing();

            // Close current stage (returns false if user cancels closing prefab scene)
            if (!CleanupCurrentStageBeforeSwitchingStage())
            {
                return(false);
            }

            newStage.setSelectionAndScrollWhenBecomingCurrentStage = setPreviousSelection;

            if (stageChanging != null)
            {
                stageChanging(currentItem, newStage);
            }

            // Switch to new stage.
            if (!newStage.isMainStage)
            {
                // Create prefab stage and add it to the list of Prefab stages before loading the prefab contents so the
                // user callbacks Awake and OnEnable are able to query the current prefab stage
                PrefabStage prefabStage = new PrefabStage();
                m_PrefabStages.Add(prefabStage);

                var success = prefabStage.OpenStage(newStage.prefabAssetPath);
                if (!success)
                {
                    m_PrefabStages.RemoveAt(m_PrefabStages.Count - 1);
                    return(false);
                }
            }

            // Set new stage after we allowed the user to cancel changing stage
            OnStageSwitched(newStage, setAsFirstItemAfterMainStage, changeTypeAnalytics);

            return(true);
        }
コード例 #11
0
 public void AddItem(StageNavigationItem item)
 {
     m_History.Add(item);
     m_CurrentIndex = m_History.Count - 1;
 }