public static string GetPath(Hash128 sceneGUID, PathType type, string subsectionName)
        {
            if (sceneGUID == new Hash128())
            {
                return("");
            }

            string sceneName = sceneGUID.ToString();

            if (!String.IsNullOrEmpty(subsectionName))
            {
                sceneName += "_" + subsectionName;
            }

            if (type == PathType.EntitiesSharedComponents)
            {
                return("Assets/EntityCache/Resources/" + sceneName + "_shared.prefab");
            }
            if (type == PathType.EntitiesHeader)
            {
                return("Assets/EntityCache/Resources/" + sceneName + "_header.asset");
            }
            if (type == PathType.EntitiesBinary)
            {
                return("Assets/StreamingAssets/EntityCache/" + sceneName + ".entities");
            }
            throw new ArgumentException();
        }
Beispiel #2
0
        public static string CalculateStreamingAssetsPath(Hash128 containerIdentifier)
        {
            StringBuilder sb = new StringBuilder(128);

            sb.Append(Application.streamingAssetsPath);
            sb.Append("/SavedSceneStates/");
            sb.Append(containerIdentifier.ToString());
            sb.Append(".sav");
            return(sb.ToString());
        }
        public void Validate(Hash128 guid)
        {
            if (!_Assets.TryGetValue(guid, out var resolved))
            {
                Debug.LogError("GlobalAssetObjectResolver Validate failed! => GUID not known");
                return;
            }

            if (resolved.AssetBundle == null)
            {
                Debug.LogError($"GlobalAssetObjectResolver Validate failed! => AssetBundle '{guid.ToString()}' not loadable");
                return;
            }

            if (resolved.AssetObjectManifest == null)
            {
                if (!resolved.AssetBundle.isStreamedSceneAssetBundle)
                {
                    Debug.LogError($"GlobalAssetObjectResolver Validate failed! => ObjectManifest in '{guid.ToString()}' not loadable");
                }
                return;
            }

//@TODO: We currently have no way of stripping objects that are editor only,
// so we can't perform these checks because some of these objects will in fact be null
#if false
            for (int i = 0; i < resolved.AssetObjectManifest.Objects.Length; i++)
            {
                Object obj = resolved.AssetObjectManifest.Objects[i];
                if (obj == null)
                {
                    //@TODO: Follow up with ryan why these are failing
                    if (guid.ToString() != k_BuiltInResourcesGuid)
                    {
                        Debug.LogError($"Object in '{guid.ToString()}' not loadable at index {i}.");
                    }
                }
            }
#endif
        }
        public void Update(List <LiveLinkChangeSet> changeSets, NativeList <Hash128> loadScenes, NativeList <Hash128> unloadScenes, LiveLinkMode mode)
        {
            if (_LoadedScenes.Count == 0 && _SceneGUIDToLiveLink.Count == 0 && _RemovedScenes.Length == 0)
            {
                return;
            }

            // If build configuration changed, we need to trigger a full conversion
            if (_BuildConfigurationGUID != default)
            {
                // TODO: Allocs, needs better API
                var buildConfigurationDependencyHash = AssetDatabase.GetAssetDependencyHash(AssetDatabase.GUIDToAssetPath(_BuildConfigurationGUID.ToString()));
                if (_BuildConfigurationArtifactHash != buildConfigurationDependencyHash)
                {
                    _BuildConfigurationArtifactHash = buildConfigurationDependencyHash;
                    RequestCleanConversion();
                }
            }

            if (_PreviousGlobalDirtyID != GlobalDirtyID)
            {
                RequestCleanConversion();
                _PreviousGlobalDirtyID = GlobalDirtyID;
            }

            // By default all scenes need to have m_GameObjectSceneCullingMask, otherwise they won't show up in game view
            _GUIDToEditScene.Clear();
            for (int i = 0; i != EditorSceneManager.sceneCount; i++)
            {
                var scene     = EditorSceneManager.GetSceneAt(i);
                var sceneGUID = new GUID(AssetDatabase.AssetPathToGUID(scene.path));

                if (_LoadedScenes.Contains(sceneGUID))
                {
                    if (scene.isLoaded && sceneGUID != default(GUID))
                    {
                        _GUIDToEditScene.Add(sceneGUID, scene);
                    }
                }
            }

            foreach (var scene in _SceneGUIDToLiveLink)
            {
                if (!_GUIDToEditScene.ContainsKey(scene.Key))
                {
                    unloadScenes.Add(scene.Key);
                }
            }

            // Process scenes that are no longer loaded
            foreach (var scene in unloadScenes)
            {
                var liveLink = _SceneGUIDToLiveLink[scene];
                liveLink.Dispose();
                _SceneGUIDToLiveLink.Remove(scene);
                _SentLoadScenes.Remove(scene);
            }
            foreach (var scene in _RemovedScenes)
            {
                if (_SceneGUIDToLiveLink.TryGetValue(scene, out var liveLink))
                {
                    liveLink.Dispose();
                    _SceneGUIDToLiveLink.Remove(scene);
                }

                unloadScenes.Add(scene);
                _SentLoadScenes.Remove(scene);
            }
            _RemovedScenes.Clear();

            _SentLoadScenes.RemoveWhere(scene => !_LoadedScenes.Contains(scene));

            // Process all scenes that the player needs
            foreach (var sceneGuid in _LoadedScenes)
            {
                var isLoaded = _GUIDToEditScene.TryGetValue(sceneGuid, out var scene);

                // We are editing with live link. Ensure it is active & up to date
                if (isLoaded)
                {
                    var liveLink = GetLiveLink(sceneGuid);
                    if (liveLink == null || liveLink.DidRequestUpdate() || liveLink.LiveLinkDirtyID != GetSceneDirtyID(scene))
                    {
                        AddLiveLinkChangeSet(sceneGuid, changeSets, mode);
                    }
                }
                else
                {
                    if (_SentLoadScenes.Add(sceneGuid))
                    {
                        loadScenes.Add(sceneGuid);
                    }
                }
            }
        }