Skip to content

Instantly share code, notes, and snippets.

/Strut.cs Secret

Created May 26, 2016 05:42
Show Gist options
  • Save anonymous/702cf5630bfc7236ba52f6ec8d7cd7a4 to your computer and use it in GitHub Desktop.
Save anonymous/702cf5630bfc7236ba52f6ec8d7cd7a4 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(PhotonView))]
public class Strut : Photon.MonoBehaviour
{
public bool DestroyByRpc;
void Update()
{
if (Input.GetButtonDown ("LandingStruts")) {
if (this.gameObject.activeSelf == true) {
this.photonView.RPC("HideStrut", PhotonTargets.AllBuffered);
}
else {
this.photonView.RPC("ShowStrut", PhotonTargets.AllBuffered);
}
}
}
[RPC]
public IEnumerator HideStrut()
{
GetComponent<MeshRenderer> ().enabled = false;
GetComponent<BoxCollider> ().enabled = false;
yield return 0;
PhotonNetwork.UnAllocateViewID(this.photonView.viewID);
}
[RPC]
public IEnumerator ShowStrut()
{
GetComponent<MeshRenderer> ().enabled = true;
GetComponent<BoxCollider> ().enabled = true;
yield return 0;
PhotonNetwork.UnAllocateViewID(this.photonView.viewID);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment