Jamie Greunbaum 00c171b7e5 - Finished animations for the location board.
- Reorganised a bunch of source files.
2025-06-13 20:41:36 -04:00

62 lines
1.9 KiB
C#

using UdonSharp;
using UnityEngine;
using VRC.Core.Pool;
using VRC.SDK3.Data;
using VRC.SDKBase;
using VRC.Udon;
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
public class PermissionsPanel : UdonSharpBehaviour
{
[SerializeField] private RectTransform _ListContainer;
[SerializeField] private GameObject _PlayerItemTemplate;
private DataDictionary PlayerData = new DataDictionary();
public override void OnPlayerJoined(VRCPlayerApi Player)
{
GameObject NewListItem = Instantiate<GameObject>(_PlayerItemTemplate, _ListContainer, false);
NewListItem.SetActive(true);
PermissionsPanelPlayerEntry PlayerListItem = NewListItem.GetComponent<PermissionsPanelPlayerEntry>();
PlayerListItem.PlayerNameUI.text = Player.displayName;
PlayerData[Player.displayName] = new DataDictionary();
PlayerData[Player.displayName].DataDictionary["Admin"] = Player.isInstanceOwner;
PlayerData[Player.displayName].DataDictionary["Host"] = Player.isInstanceOwner;
PlayerData[Player.displayName].DataDictionary["Camera"] = Player.isInstanceOwner;
if (Networking.LocalPlayer.isInstanceOwner)
{
PlayerListItem.AdminToggle.interactable = true;
PlayerListItem.HostToggle.interactable = true;
PlayerListItem.CameraToggle.interactable = true;
PlayerListItem.AdminToggle.SetIsOnWithoutNotify(true);
PlayerListItem.HostToggle.SetIsOnWithoutNotify(true);
PlayerListItem.CameraToggle.SetIsOnWithoutNotify(true);
}
base.OnPlayerJoined(Player);
}
public override void OnPlayerLeft(VRCPlayerApi player)
{
for (int i = 0; i < _ListContainer.childCount; i++)
{
GameObject Entry = _ListContainer.GetChild(i).gameObject;
PermissionsPanelPlayerEntry PlayerEntry = Entry.GetComponent<PermissionsPanelPlayerEntry>();
if (PlayerEntry != null && PlayerEntry.PlayerNameUI.text == player.displayName)
{
Destroy(Entry);
break;
}
}
base.OnPlayerLeft(player);
}
}