How can I change the scene Skybox for all players in a room?
I've tried this with no success:
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
public class SkyboxManager : MonoBehaviour
{
PhotonView m_photonView;
public Material[] myMaterials = new Material[1];
void Start()
{
m_photonView = GetComponent<PhotonView>();
}
[PunRPC]
public void StartNetworkSkybox(int pos)
{
RenderSettings.skybox = myMaterials[pos];
}
}
any help would be appreciated
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
public class SkyboxManager : MonoBehaviour
{
PhotonView m_photonView;
public Material[] myMaterials = new Material[1];
void Start()
{
m_photonView = GetComponent<PhotonView>();
}
[PunRPC]
public void StartNetworkSkybox(int pos)
{
RenderSettings.skybox = myMaterials[pos];
}
}
any help would be appreciated
0
Best Answers
-
Well.... yeah, but where did you call the RPC method? If you write in the Start something like....
void Start() { m_photonView = GetComponent<PhotonView>(); m_photonView .RPC("StartNetworkSkybox", RpcTarget.AllViaServer, 0); }
That should do the trick and it will be called for every user that has this script in the scene.1 -
well... what you're doing is to send that information in a buffer which will be called every time when a new user will connect to that room. From my experience, this method will be called for every user connected when a new user will connect. What I did was to send that info to every user connected at this moment in time. The new users won't call that method until you will call it again. Also, I did this through the server so my master is not going to send that for every single user connected.
No problem. I'm glad I could help0
Answers
-
Well.... yeah, but where did you call the RPC method? If you write in the Start something like....
void Start() { m_photonView = GetComponent<PhotonView>(); m_photonView .RPC("StartNetworkSkybox", RpcTarget.AllViaServer, 0); }
That should do the trick and it will be called for every user that has this script in the scene.1 -
@DarkSealer thank you - got it running!
what's the difference to
photonView.RPC("StartNetworkSkybox", RpcTarget.AllBuffered, pos);
?0 -
well... what you're doing is to send that information in a buffer which will be called every time when a new user will connect to that room. From my experience, this method will be called for every user connected when a new user will connect. What I did was to send that info to every user connected at this moment in time. The new users won't call that method until you will call it again. Also, I did this through the server so my master is not going to send that for every single user connected.
No problem. I'm glad I could help0