Skip to content

Instantly share code, notes, and snippets.

@ManickYoj
Last active January 2, 2022 22:16
Show Gist options
  • Save ManickYoj/c763cf76b96378f2ceb6301618e9fc07 to your computer and use it in GitHub Desktop.
Save ManickYoj/c763cf76b96378f2ceb6301618e9fc07 to your computer and use it in GitHub Desktop.
[RequireComponent(typeof(PlayerInput))]
public class Transmitter : MonoBehaviour {
private Receiver receiver;
private PlayerInput playerInput;
void Start() {
this.playerInput = this.GetComponent<PlayerInput>();
this.playerInput.enabled = true;
Registry.Instance.GetNewReceiver(this);
}
public void Connect(Receiver receiver) {
// Somewhat clumsily, be sure that evey other possible camera is disabled
// we activate the new one.
foreach(Camera c in Camera.allCameras) c.gameObject.SetActive(false);
this.receiver = receiver;
this.receiver.receiverCamera.gameObject.SetActive(true);
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment