Пример #1
0
        unsafe void ReceiveAssetTargetHash(MessageEventArgs args)
        {
            using (var resolvedAssets = args.ReceiveArray <ResolvedAssetID>())
            {
                foreach (var asset in resolvedAssets)
                {
                    if (!asset.TargetHash.IsValid)
                    {
                        // If hash is invalid, then it means we should be waiting on it, but the hash will come later when it finishes importing on the editor
                        LiveLinkMsg.LogReceived($"ReceiveAssetTargetHash => {asset.GUID} | {asset.TargetHash}, Invalid Hash (Still waiting)");
                        m_WaitingForAssets[asset.GUID] = new Hash128();
                    }
                    else
                    {
                        //TODO: Should we compare against already loaded assets here?
                        if (File.Exists(GetCachePath(asset.TargetHash)))
                        {
                            LiveLinkMsg.LogReceived($"ReceiveAssetTargetHash => {asset.GUID} | {asset.TargetHash}, File.Exists => 'True'");
                            m_WaitingForAssets[asset.GUID] = asset.TargetHash;
                        }
                        else
                        {
                            LiveLinkMsg.LogReceived($"ReceiveAssetTargetHash => {asset.GUID} | {asset.TargetHash}, File.Exists => 'False'");
                            m_WaitingForAssets[asset.GUID] = new Hash128();

                            LiveLinkMsg.LogSend($"AssetBundleBuild request '{asset.GUID}'");
                            PlayerConnection.instance.Send(LiveLinkMsg.RequestAssetByGUID, asset.GUID);
                        }
                    }
                }
            }
        }
Пример #2
0
        protected override void OnUpdate()
        {
            // BuildConfigurationGUID isn't known in OnCreate since it could be configured from OnCreate of other systems,
            // So we delay connecting live link until first OnUpdate
            if (!m_DidRequestConnection)
            {
                if (!m_SessionHandshake)
                {
                    if (m_SessionHandshakeTimeoutTimstamp < Time.ElapsedTime)
                    {
                        Debug.LogError("LiveLink handshake timed out. This may be because your player connection is connected to an AssetWorker process or incorrect Editor.");
                        World.GetExistingSystem <LiveLinkRuntimeSystemGroup>().Enabled = false;
                    }

                    return;
                }

                m_DidRequestConnection = true;
                LiveLinkMsg.LogSend("ConnectLiveLink");
                m_Connection.Send(LiveLinkMsg.PlayerRequestConnectLiveLink, World.GetExistingSystem <SceneSystem>().BuildConfigurationGUID);
            }

            SendSetLoadedScenes();

            while (m_ResourcePacketQueue.Count != 0 && IsResourceReady(m_ResourcePacketQueue.Peek().GlobalObjectIds))
            {
                LiveLinkMsg.LogInfo($"Applying changeset ({m_ResourcePacketQueue.Count-1} left in queue)");
                using (var resourcePacket = m_ResourcePacketQueue.Dequeue())
                {
                    ApplyChangeSet(resourcePacket);
                }
            }
        }
Пример #3
0
        void ResetGame()
        {
            while (m_ResourcePacketQueue.Count != 0)
            {
                m_ResourcePacketQueue.Dequeue().Dispose();
            }

            EntityManager.DestroyEntity(EntityManager.UniversalQuery);

            //@TODO: Once we have build settings & loading of game object scenes we can remove this hack.
            var scenes = Object.FindObjectsOfType <SubScene>();

            foreach (var scene in scenes)
            {
                scene.enabled = false;
                scene.enabled = true;
            }

            LiveLinkPlayerAssetRefreshSystem.Reset();

            LiveLinkMsg.LogSend("ConnectLiveLink");
            PlayerConnection.instance.Send(LiveLinkMsg.ConnectLiveLink, World.GetExistingSystem <SceneSystem>().BuildSettingsGUID);

            m_LiveLinkSceneChange.Reset();
            SendSetLoadedScenes();
        }
Пример #4
0
 void SendSetLoadedScenes()
 {
     if (m_LiveLinkSceneChange.GetSceneMessage(out var msg))
     {
         LiveLinkMsg.LogSend($"SetLoadedScenes: Loaded {msg.LoadedScenes.ToDebugString()}, Removed {msg.RemovedScenes.ToDebugString()}");
         m_Connection.Send(LiveLinkMsg.PlayerSetLoadedScenes, msg.ToMsg());
         msg.Dispose();
     }
 }
Пример #5
0
        void ResetGame()
        {
            var sceneSystem = World.GetExistingSystem <SceneSystem>();

            sceneSystem.UnloadAllScenes();

            while (m_ResourcePacketQueue.Count != 0)
            {
                m_ResourcePacketQueue.Dequeue().Dispose();
            }

            EntityManager.DestroyEntity(EntityManager.UniversalQuery);
            LiveLinkPlayerAssetRefreshSystem.Reset();

            LiveLinkMsg.LogSend("ConnectLiveLink");
            m_Connection.Send(LiveLinkMsg.PlayerRequestConnectLiveLink, sceneSystem.BuildConfigurationGUID);

            m_LiveLinkSceneChange.Reset();
            SendSetLoadedScenes();
        }
        protected override void OnUpdate()
        {
            // Request any new guids that we haven't seen yet from the editor
            using (var requestedGuids = _ResourceRequests.ToComponentDataArray <ResourceGUID>(Allocator.TempJob))
            {
                if (requestedGuids.Length > 0)
                {
                    EntityManager.AddComponent(_ResourceRequests, typeof(ResourceRequested));
                    LiveLinkMsg.LogSend($"AssetBundleTargetHash request {requestedGuids.Reinterpret<Hash128>().ToDebugString()}");
                    PlayerConnection.instance.SendArray(LiveLinkMsg.RequestAssetBundleTargetHash, requestedGuids);
                }
            }

            // * Ensure all assets we are waiting for have arrived.
            // * LoadAll asset bundles in one go when everything is ready
            if (_WaitingForAssets.Count != 0)
            {
                bool hasAllAssets = true;
                var  assets       = new NativeArray <ResolvedAssetID>(_WaitingForAssets.Count, Allocator.TempJob);
                int  o            = 0;
                foreach (var asset in _WaitingForAssets)
                {
                    if (asset.Value == new Hash128())
                    {
                        hasAllAssets = false;
                    }
                    assets[o++] = new ResolvedAssetID {
                        GUID = asset.Key, TargetHash = asset.Value
                    };
                }

                if (hasAllAssets)
                {
                    LoadAssetBundles(assets);
                    _WaitingForAssets.Clear();
                }

                assets.Dispose();
            }
        }
Пример #7
0
        protected override void OnUpdate()
        {
            var sceneSystem = World.GetExistingSystem <SceneSystem>();

            Entities.With(m_AllScenes).ForEach((Entity e, ref SceneReference sceneRef) =>
            {
                if (m_LiveLinkedScenes.Contains(sceneRef.SceneGUID))
                {
                    EntityManager.AddComponent <DisableSceneResolveAndLoad>(e);
                }
                else
                {
                    EntityManager.RemoveComponent <DisableSceneResolveAndLoad>(e);
                }
            }
                                               );


            // BuildSettingsGUID isn't known in OnCreate since it could be configured from OnCreate of other systems,
            // So we delay connecting live link until first OnUpdate
            if (!m_DidRequestConnection)
            {
                m_DidRequestConnection = true;
                LiveLinkMsg.LogSend("ConnectLiveLink");
                PlayerConnection.instance.Send(LiveLinkMsg.ConnectLiveLink, World.GetExistingSystem <SceneSystem>().BuildSettingsGUID);
            }

            SendSetLoadedScenes();

            while (m_ResourcePacketQueue.Count != 0 && IsResourceReady(m_ResourcePacketQueue.Peek()))
            {
                LiveLinkMsg.LogInfo($"Applying changeset ({m_ResourcePacketQueue.Count-1} left in queue)");
                using (var resourcePacket = m_ResourcePacketQueue.Dequeue())
                {
                    ApplyChangeSet(resourcePacket);
                }
            }
        }
        unsafe void ReceiveResponseAssetBundleTargetHash(MessageEventArgs args)
        {
            using (var resolvedAssets = args.ReceiveArray <ResolvedAssetID>())
            {
                foreach (var asset in resolvedAssets)
                {
                    //TODO: Should we compare against already loaded assets here?
                    if (File.Exists(GetCachePath(asset.TargetHash)))
                    {
                        LiveLinkMsg.LogReceived($"AssetBundleTargetHash => {asset.GUID} | {asset.TargetHash}, File.Exists => 'True'");
                        _WaitingForAssets[asset.GUID] = asset.TargetHash;
                    }
                    else
                    {
                        LiveLinkMsg.LogReceived($"AssetBundleTargetHash => {asset.GUID} | {asset.TargetHash}, File.Exists => 'False'");
                        _WaitingForAssets[asset.GUID] = new Hash128();

                        LiveLinkMsg.LogSend($"AssetBundleBuild request '{asset.GUID}'");
                        PlayerConnection.instance.Send(LiveLinkMsg.RequestAssetBundleForGUID, asset.GUID);
                    }
                }
            }
        }
Пример #9
0
        protected override void OnUpdate()
        {
            var sceneSystem = World.GetExistingSystem <SceneSystem>();

            // BuildConfigurationGUID isn't known in OnCreate since it could be configured from OnCreate of other systems,
            // So we delay connecting live link until first OnUpdate
            if (!m_DidRequestConnection)
            {
                m_DidRequestConnection = true;
                LiveLinkMsg.LogSend("ConnectLiveLink");
                PlayerConnection.instance.Send(LiveLinkMsg.RequestConnectLiveLink, World.GetExistingSystem <SceneSystem>().BuildConfigurationGUID);
            }

            SendSetLoadedScenes();

            while (m_ResourcePacketQueue.Count != 0 && IsResourceReady(m_ResourcePacketQueue.Peek().GlobalObjectIds))
            {
                LiveLinkMsg.LogInfo($"Applying changeset ({m_ResourcePacketQueue.Count-1} left in queue)");
                using (var resourcePacket = m_ResourcePacketQueue.Dequeue())
                {
                    ApplyChangeSet(resourcePacket);
                }
            }
        }