Пример #1
0
        [ClientRpc] // @ remote client
        public void RpcClientChangeNamedAvatar(int humanoidId, string avatarPrefabName)
        {
            if (debug <= HumanoidNetworking.Debug.Info)
            {
                Debug.Log(netId.Value + ": RpcChangeAvatar " + humanoidId + "to: " + avatarPrefabName);
            }

            HumanoidControl humanoid = HumanoidNetworking.FindRemoteHumanoid(humanoids, humanoidId);

            if (humanoid == null)
            {
                if (debug <= HumanoidNetworking.Debug.Warning)
                {
                    Debug.LogWarning(netId.Value + ": Could not find humanoid: " + humanoidId);
                }
                return;
            }

            GameObject remoteAvatar = (GameObject)Resources.Load(avatarPrefabName);

            if (remoteAvatar == null)
            {
                if (debug <= HumanoidNetworking.Debug.Error)
                {
                    Debug.LogError("Could not load remote avatar " + avatarPrefabName + ". Is it located in a Resources folder?");
                }
                return;
            }
            humanoid.LocalChangeAvatar(remoteAvatar);
        }
Пример #2
0
        public static HumanoidControl StartHumanoid(
            int nwId,
            int humanoidId,
            string name,
            string avatarPrefabName,
            Vector3 position, Quaternion rotation,
            bool physics)
        {
            if (debug <= Debug.Info)
            {
                UnityEngine.Debug.Log(nwId + ": Receive StartHumanoid " + humanoidId);
            }

            HumanoidControl remoteHumanoid = InstantiateRemoteHumanoid(remoteHumanoidPrefab, name, position, rotation);

            remoteHumanoid.nwId       = nwId;
            remoteHumanoid.humanoidId = humanoidId;

            if (debug <= Debug.Info)
            {
                UnityEngine.Debug.Log(remoteHumanoid.nwId + ": Remote Humanoid " + remoteHumanoid.humanoidId + " Added");
            }

            GameObject remoteAvatar = (GameObject)Resources.Load(avatarPrefabName);

            if (remoteAvatar == null)
            {
                if (debug <= Debug.Error)
                {
                    UnityEngine.Debug.LogError("Could not load remote avatar " + avatarPrefabName + ". Is it located in a Resources folder?");
                }
                return(remoteHumanoid);
            }
            remoteHumanoid.physics = physics;
            remoteHumanoid.LocalChangeAvatar(remoteAvatar);

            return(remoteHumanoid);
        }