I Wrote this very simple Script to check the reason of the error that i got with my other project .
I Am using photon Pun 2
using Photon.Pun;
using Photon.Realtime;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon;
using UnityEngine.UI;
public class Start_Here : MonoBehaviourPunCallbacks {
public GameObject prefab;
private GameObject My_Prefab;
private PhotonView PV;
public Transform parents;
public InputField InputText;
public TextMesh txt;
void Start ()
{
if (!PhotonNetwork.IsConnected)
PhotonNetwork.ConnectUsingSettings();
PhotonNetwork.LocalPlayer.NickName = "Tamim"+Random.Range(1,1000).ToString();
InputText.text = "Tamim";
}
public override void OnConnectedToMaster()
{
Debug.Log("We Are Connected to " + PhotonNetwork.CloudRegion + " ServerSettings!..........");
PhotonNetwork.AutomaticallySyncScene = true;
PhotonNetwork.JoinLobby(TypedLobby.Default);
}
public override void OnJoinedLobby()
{
RoomOptions ro = new RoomOptions() { IsVisible = true, IsOpen = true, MaxPlayers = 10 };
PhotonNetwork.JoinOrCreateRoom("RG5", ro, TypedLobby.Default, null);
}
public override void OnJoinedRoom()
{
My_Prefab = PhotonNetwork.Instantiate("Sphere", new Vector3(0, 70, 0), Quaternion.identity, 0);
My_Prefab.transform.SetParent(parents);
PV = My_Prefab.GetComponent<PhotonView>();
txt = My_Prefab.GetComponentInChildren<TextMesh>();
if (PV.IsMine)
PV.RPC("Change_Name1", RpcTarget.All, InputText.text);
}
[PunRPC]
public void Change_Name1(string ss)
{
InputText.text= ss + Random.Range(1, 100).ToString();
}
public override void OnPlayerEnteredRoom(Player newPlayer)
{
Debug.Log("Player Enterd The Room");
}
void OnGUI()
{
//GUI.Label(new Rect(50, 10, 400, 500 + 20), PhotonNetwork.NetworkClientState.ToString());
//2 += 5;
}
}
1-every client i run i got the error
here i run two clients , and got two errors .
2- InputText.text doesn’t change ??
Look like photon cant find the method. but it exist !!!
Any idea Please ?
PhotonView with ID 1001 has no method “Change_Name1” marked with the PunRPC or @PunRPC(JS) property! Args: String
UnityEngine.Debug:LogError(Object)
PhotonView with ID 2001 has no method “Change_Name1” marked with the PunRPC or @PunRPC(JS) property! Args: String
UnityEngine.Debug:LogError(Object)