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); } }
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>() } }); }
protected override void OnCreate() { m_Connection = PlayerConnection.instance; }
internal void SetConnection(IEditorPlayerConnection connection) { m_Connection = connection ?? throw new ArgumentNullException(nameof(connection)); }
static public void SendArray <T>(this IEditorPlayerConnection connection, Guid msgGuid, NativeArray <T> data) where T : unmanaged { connection.Send(msgGuid, SerializeUnmanagedArray(data)); }
static public void Send <T>(this IEditorPlayerConnection connection, Guid msgGuid, T data) where T : unmanaged { connection.Send(msgGuid, SerializeUnmanaged(ref data)); }