С одиночной игрой всё просто, а вот с мультиплеером не понятно. Другим игрокам не видно этой смены.
Я читал англоязычные формулу и нашёл штуку [RPC], [RPCClient], [Command]. Пытался и в свой код это вставить, ничего опять не вышло.
Прикрепляю ниже скрипт, что нужно сделать, чтобы мультиплеер заработал?
Заранее спасибо за помощь!
Синтаксис:
Используется csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.Characters.FirstPerson;
using UnityEngine.Networking;
public class CharacterManager : NetworkBehaviour {
private bool IsOpenedMenu = false;
[SerializeField]
private GUISkin skin;
[SerializeField]
private GameObject[] skins;
[RPC]
void SelectSkin(int _id) {
for (int i = 0; i < skins.Length; ++i)
skins [i].SetActive (i == _id);
}
void Start() {
SelectSkin (0);
}
void Update() {
if (Input.GetKeyDown (KeyCode.E))
IsOpenedMenu = !IsOpenedMenu;
if (IsOpenedMenu) {
if (Input.GetKeyDown (KeyCode.Alpha1))
SelectSkin (0);
if (Input.GetKeyDown (KeyCode.Alpha2))
SelectSkin (1);
if (Input.GetKeyDown (KeyCode.Alpha3))
SelectSkin (2);
}
}
void OnGUI () {
GUI.skin = skin;
if (IsOpenedMenu) {
GUI.Box (new Rect (Screen.width/2-150, Screen.height/2-50, 300, 100), "");
GUI.Box (new Rect (Screen.width / 2-150, Screen.height / 2 - 50, 100, 100), "Human(1)");
GUI.Box (new Rect (Screen.width / 2-50, Screen.height / 2 - 50, 100, 100), "Grass Block(2)");
GUI.Box (new Rect (Screen.width / 2+50, Screen.height / 2 - 50, 100, 100), "Dirty Block(3)");
}
}
}
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.Characters.FirstPerson;
using UnityEngine.Networking;
public class CharacterManager : NetworkBehaviour {
private bool IsOpenedMenu = false;
[SerializeField]
private GUISkin skin;
[SerializeField]
private GameObject[] skins;
[RPC]
void SelectSkin(int _id) {
for (int i = 0; i < skins.Length; ++i)
skins [i].SetActive (i == _id);
}
void Start() {
SelectSkin (0);
}
void Update() {
if (Input.GetKeyDown (KeyCode.E))
IsOpenedMenu = !IsOpenedMenu;
if (IsOpenedMenu) {
if (Input.GetKeyDown (KeyCode.Alpha1))
SelectSkin (0);
if (Input.GetKeyDown (KeyCode.Alpha2))
SelectSkin (1);
if (Input.GetKeyDown (KeyCode.Alpha3))
SelectSkin (2);
}
}
void OnGUI () {
GUI.skin = skin;
if (IsOpenedMenu) {
GUI.Box (new Rect (Screen.width/2-150, Screen.height/2-50, 300, 100), "");
GUI.Box (new Rect (Screen.width / 2-150, Screen.height / 2 - 50, 100, 100), "Human(1)");
GUI.Box (new Rect (Screen.width / 2-50, Screen.height / 2 - 50, 100, 100), "Grass Block(2)");
GUI.Box (new Rect (Screen.width / 2+50, Screen.height / 2 - 50, 100, 100), "Dirty Block(3)");
}
}
}