main - remote-2023-08-20T02:24:11 now-2023-08-20T18:40:38

This commit is contained in:
Adversary 2023-08-20 18:40:38 +00:00
commit 4cf5c80442
161 changed files with 12176 additions and 0 deletions

View file

@ -0,0 +1,43 @@
using UnityEngine;
using VRC.SDK3.Components;
using VRC.SDKBase;
using VRC.Udon;
namespace UdonSharp.Examples.Utilities
{
/// <summary>
/// This class allows anyone to toggle a gameobject for everyone in the world.
/// This script assumes that the object it is on will not have other things transferring ownership of it.
/// </summary>
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
public class GlobalToggleObject : UdonSharpBehaviour
{
public GameObject toggleObject;
[UdonSynced]
bool isEnabled;
private void Start()
{
isEnabled = toggleObject.activeSelf;
}
public override void OnDeserialization()
{
if (!Networking.IsOwner(gameObject))
toggleObject.SetActive(isEnabled);
}
public override void Interact()
{
if (!Networking.IsOwner(gameObject))
Networking.SetOwner(Networking.LocalPlayer, gameObject);
isEnabled = !isEnabled;
toggleObject.SetActive(isEnabled);
RequestSerialization();
}
}
}