SetActive appear for everyone
Options
Hi All,
I've been working on my final Uni project and I didn't expect making objects appear and disappear for everyone in my scene would prove so challenging. My goal is that when one player selects from a dropdown it'll show/hide for everyone, but for now im just trying to get it work with a button press. At the moment unity now just crashes when I try and test the code. Any and all advice much appreciated this kinda coding isn't usually my area.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
public class hIDEBUTTOON : MonoBehaviourPun
{
public GameObject Box;
public void PressBtn()
{
if (photonView.IsMine)
{
Debug.Log("CheckView");
if (Box != null)
{
Debug.Log("IsActive");
bool isActive = Box.activeSelf;
Box.SetActive(!isActive); //show panel
photonView.RPC("BtnPress", RpcTarget.All);
BtnPress();
}
}
}
[PunRPC]
public void BtnPress()
{
if (photonView.IsMine)
{
PressBtn();
// photonView.RPC("PressBtn", RpcTarget.All);
Debug.Log("RPC");
}
}
}
I've been working on my final Uni project and I didn't expect making objects appear and disappear for everyone in my scene would prove so challenging. My goal is that when one player selects from a dropdown it'll show/hide for everyone, but for now im just trying to get it work with a button press. At the moment unity now just crashes when I try and test the code. Any and all advice much appreciated this kinda coding isn't usually my area.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
public class hIDEBUTTOON : MonoBehaviourPun
{
public GameObject Box;
public void PressBtn()
{
if (photonView.IsMine)
{
Debug.Log("CheckView");
if (Box != null)
{
Debug.Log("IsActive");
bool isActive = Box.activeSelf;
Box.SetActive(!isActive); //show panel
photonView.RPC("BtnPress", RpcTarget.All);
BtnPress();
}
}
}
[PunRPC]
public void BtnPress()
{
if (photonView.IsMine)
{
PressBtn();
// photonView.RPC("PressBtn", RpcTarget.All);
Debug.Log("RPC");
}
}
}
0