Hello! I am using Photon (PUN 2) recently. And I have the next question
I have a button, but when I click on it from a non-master client, nothing happens. The button works, I’m sure.
Here is my code:
[SerializeField] private GameObject photonUserPrefab = default;
[SerializeField] private GameObject button = default;
[SerializeField] private GameObject cube = default;
...
private void Start()
{
if (PhotonNetwork.PrefabPool is DefaultPool pool)
{
if (photonUserPrefab != null) pool.ResourceCache.Add(photonUserPrefab.name, photonUserPrefab);
if (button != null) pool.ResourceCache.Add(button.name, button);
if (cube != null) pool.ResourceCache.Add(cube.name, cube);
}
}
...
private void CreateInteractableObjects()
{
var bb = PhotonNetwork.Instantiate(button.name, button.transform.position, button.transform.rotation);
bb.GetComponentInChildren<Interactable>().OnClick.AddListener(OnClick);
}
private void OnClick()
{
var cube_ = PhotonNetwork.Instantiate(cube.name, cube.transform.position, cube.transform.rotation);
}
Please, help me! It I really need to understand what the matter is.
[171253-без-имени.png|171253]