Unity/photon/pun2/rpc
ナビゲーションに移動
検索に移動
RpcViewScene.cs
using UnityEngine;
using Photon.Pun;
public class RpcViewScene : MonoBehaviour
{
PhotonView photonView = null;
void Awake() {
photonView = GetComponent<PhotonView>();
}
void Start() {
}
void Update() {
if (Input.GetKeyDown (KeyCode.Space)) {
SpaceKey ();
}
if (Input.GetKeyDown (KeyCode.LeftArrow)) {
LeftArrowKey ();
}
}
void SpaceKey()
{
photonView.RPC("CustomMethod", RpcTarget.All);
}
[PunRPC]
private void CustomMethod() {
Debug.Log ("CustomMethod");
}
void LeftArrowKey() {
object[] args = new object[]{
"hoge",
new string[] {"taro", "jiro", "saburo"}
};
photonView.RPC("Custom2Method", RpcTarget.All, args);
}
[PunRPC]
private void Custom2Method(string str, string[] names) {
Debug.Log ("CustomMethod " + str);
foreach (string name in names) {
Debug.Log ("CustomMethod name=" + name);
}
}
}