using Photon.Pun; using System.Collections; using System.Collections.Generic; using UnityEngine; public class ClassResourceUIManager : MonoBehaviour { public List uiElements = new List(); [SerializeField] private GameEventListener_PhotonView onPlayerSpawned; ClassResource localClassResource; RiftPlayer player; private void Awake() { for (int i = 0; i < uiElements.Count; i++) { uiElements[i].gameObject.SetActive(false); } onPlayerSpawned.Response.AddListener(OnPlayerSpawned); } private void OnPlayerSpawned(PhotonView photonView) { if (!photonView.Owner.IsLocal) return; player = photonView.GetComponent(); localClassResource = photonView.GetComponent(); if (localClassResource == null) return; for (int i = 0; i < uiElements.Count; i++) { if (uiElements[i].classTag != player.classTag) continue; uiElements[i].respectiveResource = localClassResource; localClassResource.onResourceChanged.AddListener(uiElements[i].OnResourceChanged); uiElements[i].gameObject.SetActive(true); return; } } }