Beispiel #1
0
        void AddLiveLinkChangeSet(Hash128 sceneGUID, List <LiveLinkChangeSet> changeSets, LiveLinkMode mode)
        {
            var liveLink  = GetLiveLink(sceneGUID);
            var editScene = _GUIDToEditScene[sceneGUID];

            // The current behaviour is that we do incremental conversion until we release the hot control
            // This is to avoid any unexpected stalls
            // Optimally the undo system would tell us if only properties have changed, but currently we don't have such an event stream.
            var sceneDirtyID   = GetSceneDirtyID(editScene);
            var updateLiveLink = true;

            if (IsHotControlActive())
            {
                if (liveLink != null)
                {
                    sceneDirtyID = liveLink.LiveLinkDirtyID;
                }
                else
                {
                    updateLiveLink = false;
                    EditorUpdateUtility.EditModeQueuePlayerLoopUpdate();
                }
            }
            else
            {
                if (liveLink != null && liveLink.LiveLinkDirtyID != sceneDirtyID)
                {
                    liveLink.RequestCleanConversion();
                }
            }

            if (updateLiveLink)
            {
                //@TODO: need one place that LiveLinkDiffGenerators are managed. UpdateLiveLink does a Dispose()
                // but this must be paired with membership in _SceneGUIDToLiveLink. not good to have multiple places
                // doing ownership management.
                //
                // also: when implementing an improvement to this, be sure to deal with exceptions, which can occur
                // during conversion.

                if (liveLink != null)
                {
                    _SceneGUIDToLiveLink.Remove(sceneGUID);
                }

                try
                {
                    changeSets.Add(LiveLinkDiffGenerator.UpdateLiveLink(editScene, sceneGUID, ref liveLink, sceneDirtyID, mode, _BuildSettings));
                }
                finally
                {
                    if (liveLink != null)
                    {
                        _SceneGUIDToLiveLink.Add(sceneGUID, liveLink);
                    }
                }
            }
        }
        void AddLiveLinkChangeSet(ref LiveLinkDiffGenerator liveLink, Hash128 sceneGUID, List <LiveLinkChangeSet> changeSets, LiveLinkMode mode)
        {
            var editScene = _GUIDToEditScene[sceneGUID];

            int sceneDirtyID = 0;

#if !UNITY_2020_2_OR_NEWER
            // The current behaviour is that we do incremental conversion until we release the hot control
            // This is to avoid any unexpected stalls
            if (IsHotControlActive())
            {
                if (liveLink == null)
                {
                    EditorUpdateUtility.EditModeQueuePlayerLoopUpdate();
                    return;
                }
                sceneDirtyID = liveLink.LiveLinkDirtyID;
            }
            else
            {
                sceneDirtyID = GetSceneDirtyID(editScene);
                if (liveLink != null && liveLink.LiveLinkDirtyID != sceneDirtyID)
                {
                    liveLink.RequestCleanConversion();
                }
            }
#endif

            //@TODO: need one place that LiveLinkDiffGenerators are managed. UpdateLiveLink does a Dispose()
            // but this must be paired with membership in _SceneGUIDToLiveLink. not good to have multiple places
            // doing ownership management.
            //
            // also: when implementing an improvement to this, be sure to deal with exceptions, which can occur
            // during conversion.

            if (liveLink != null)
            {
                _SceneGUIDToLiveLink.Remove(sceneGUID);
            }

            try
            {
                changeSets.Add(LiveLinkDiffGenerator.UpdateLiveLink(editScene, sceneGUID, ref liveLink, sceneDirtyID, mode, _BuildConfigurationGUID, _BuildConfiguration));
            }
            finally
            {
                if (liveLink != null)
                {
                    _SceneGUIDToLiveLink.Add(sceneGUID, liveLink);
                }
            }
        }