49 lines
921 B
C#
49 lines
921 B
C#
|
|
using UdonSharp;
|
|
using UnityEngine;
|
|
using VRC.SDKBase;
|
|
using VRC.Udon.Common;
|
|
|
|
|
|
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
|
|
public class PositionMarker : UdonSharpBehaviour
|
|
{
|
|
[SerializeField] private GameObject _Marker;
|
|
|
|
[UdonSynced] private string _PlayerName = "";
|
|
|
|
|
|
public override void OnDeserialization(DeserializationResult Result)
|
|
{
|
|
_SetPlayer_Synced();
|
|
base.OnDeserialization(Result);
|
|
}
|
|
|
|
public void SetPlayer(string Name)
|
|
{
|
|
Networking.SetOwner(Networking.LocalPlayer, gameObject);
|
|
|
|
_PlayerName = Name;
|
|
_SetPlayer_Synced();
|
|
RequestSerialization();
|
|
}
|
|
private void _SetPlayer_Synced()
|
|
{
|
|
_Marker.SetActive(Networking.LocalPlayer.displayName == _PlayerName);
|
|
}
|
|
|
|
public void ClearPlayer()
|
|
{
|
|
Networking.SetOwner(Networking.LocalPlayer, gameObject);
|
|
|
|
_PlayerName = "";
|
|
_SetPlayer_Synced();
|
|
RequestSerialization();
|
|
}
|
|
|
|
public bool IsSet()
|
|
{
|
|
return _PlayerName != "";
|
|
}
|
|
}
|