public void Bind(IEditorPlayerConnection connection, bool isConnected)
        {
            if (m_Connection != null)
            {
                if (m_Connection == connection)
                {
                    return;
                }
                throw new InvalidOperationException("Already bound to an IEditorPlayerConnection");
            }

            // If there's already connections on the given IEditorPlayerConnection,
            // calling RegisterConnection() will invoke the given callback for every
            // already existing connection. However, it seems to do so only in the
            // editor which is why we do the 'isConnected' dance below.
            connection.RegisterConnection(OnConnected);

            connection.RegisterDisconnection(OnDisconnected);

            connection.Register(kNewDeviceMsg, OnNewDevice);
            connection.Register(kNewTemplateMsg, OnNewTemplate);
            connection.Register(kNewEventsMsg, OnNewEvents);
            connection.Register(kRemoveDeviceMsg, OnRemoveDevice);
            connection.Register(kChangeUsagesMsg, OnChangeUsages);

            m_Connection = connection;

            if (isConnected)
            {
                OnConnected(0);
            }
        }
예제 #2
0
        protected override void OnStartRunning()
        {
            Debug.Log("Initializing live link");
            m_Connection.Register(LiveLinkMsg.EditorResponseHandshakeLiveLink, ResponseSessionHandshake);
            m_Connection.Register(LiveLinkMsg.EditorReceiveEntityChangeSet, ReceiveEntityChangeSet);
            m_Connection.Register(LiveLinkMsg.EditorUnloadScenes, ReceiveUnloadScenes);
            m_Connection.Register(LiveLinkMsg.EditorLoadScenes, ReceiveLoadScenes);
            m_Connection.Register(LiveLinkMsg.EditorResetGame, ReceiveResetGame);
            m_Connection.Register(LiveLinkMsg.EditorResponseConnectLiveLink, ReceiveInitialScenes);

            m_ResourcePacketQueue = new Queue <EntityChangeSetSerialization.ResourcePacket>();
            m_Resources           = GetEntityQuery(new EntityQueryDesc
            {
                All = new[] { ComponentType.ReadOnly <ResourceGUID>() }
            });

            m_Patcher = new LiveLinkPatcher(World);

            m_LiveLinkSceneChange = new LiveLinkSceneChangeTracker(EntityManager);

            // Send handshake and set timeout
            PlayerConnection.instance.Send(LiveLinkMsg.PlayerRequestHandshakeLiveLink, new byte[0]);
            m_SessionHandshakeTimeoutTimstamp = Time.ElapsedTime + kSessionHandshakeTimeout;
            m_SessionHandshake = false;
        }
예제 #3
0
        protected override void OnStartRunning()
        {
            m_Connection = m_PlayerSystem.Connection;
            m_Connection.Register(LiveLinkMsg.EditorResponseAssetForGUID, ReceiveAsset);
            m_Connection.Register(LiveLinkMsg.EditorResponseAssetTargetHash, ReceiveAssetTargetHash);

            m_Connection.Register(LiveLinkMsg.EditorResponseSubSceneTargetHash, ReceiveSubSceneTargetHash);
            m_Connection.Register(LiveLinkMsg.EditorResponseSubSceneForGUID, ReceiveSubScene);

            m_Connection.Register(LiveLinkMsg.EditorSendBuildArtifact, ReceiveBuildArtifact);

            m_ResourceRequests = GetEntityQuery(new EntityQueryDesc
            {
                All  = new[] { ComponentType.ReadOnly <ResourceGUID>() },
                None = new[] { ComponentType.ReadOnly <ResourceRequested>(), ComponentType.ReadOnly <ResourceLoaded>() }
            });

            m_SubSceneAssetRequests = GetEntityQuery(new EntityQueryDesc
            {
                All  = new[] { ComponentType.ReadOnly <SubSceneGUID>() },
                None = new[] { ComponentType.ReadOnly <SubSceneRequested>() }
            });
        }