UnityEngine.Networking.NetworkConnection.AddOwnedObject C# (CSharp) Method

AddOwnedObject() private method

private AddOwnedObject ( NetworkIdentity obj ) : void
obj NetworkIdentity
return void
        internal void AddOwnedObject(NetworkIdentity obj)
        {
            if (this.m_ClientOwnedObjects == null)
            {
                this.m_ClientOwnedObjects = new HashSet<NetworkInstanceId>();
            }
            this.m_ClientOwnedObjects.Add(obj.netId);
        }

Usage Example

コード例 #1
0
        public bool AssignClientAuthority(NetworkConnection conn)
        {
            if (!isServer)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("AssignClientAuthority can only be call on the server for spawned objects.");
                }
                return(false);
            }
            if (!localPlayerAuthority)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("AssignClientAuthority can only be used for NetworkIdentity component with LocalPlayerAuthority set.");
                }
                return(false);
            }

            if (m_ClientAuthorityOwner != null && conn != m_ClientAuthorityOwner)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("AssignClientAuthority for " + gameObject + " already has an owner. Use RemoveClientAuthority() first.");
                }
                return(false);
            }

            if (conn == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("AssignClientAuthority for " + gameObject + " owner cannot be null. Use RemoveClientAuthority() instead.");
                }
                return(false);
            }

            m_ClientAuthorityOwner = conn;
            m_ClientAuthorityOwner.AddOwnedObject(this);

            // server no longer has authority (this is called on server). Note that local client could re-acquire authority below
            ForceAuthority(false);

            // send msg to that client
            var msg = new ClientAuthorityMessage();

            msg.netId     = netId;
            msg.authority = true;
            conn.Send((short)MsgType.LocalClientAuthority, msg);

            if (clientAuthorityCallback != null)
            {
                clientAuthorityCallback(conn, this, true);
            }
            return(true);
        }
All Usage Examples Of UnityEngine.Networking.NetworkConnection::AddOwnedObject