using System; using System.Collections.Generic; using System.Linq; using UnityEngine; using UnityEngine.Android; using static ENMenu; public class EN : MonoBehaviour { public static EN instance; public List users = new List(); public User SelectedUser; public User Me; // ✅ Lists for meetings and spaces public List meetings = new List(); public List spaces = new List(); public string selectedSpaceUrl; public string selectedSpaceId; public GameObject Error; void Awake() { if (EN.instance) { Destroy(gameObject); return; } DontDestroyOnLoad(this.gameObject); instance = this; } public void Start() { if (!Permission.HasUserAuthorizedPermission(Permission.Microphone)) { Permission.RequestUserPermission(Permission.Microphone); } // Optionally preload meetings and spaces if Me is available // StartCoroutine(webservice.instance.GetUserMeetings(OnMeetingsLoaded)); // StartCoroutine(webservice.instance.GetSpaces(OnSpacesLoaded)); } // ✅ Callback to populate meetings list public void OnMeetingsLoaded(MeetingResponse response) { if (response != null && response.meetings != null) { meetings = response.meetings; Debug.Log("Meetings loaded: " + meetings.Count); } else { showError("خطا", "بارگذاری جلسات با خطا مواجه شد"); } } // ✅ Callback to populate spaces list public void OnSpacesLoaded(SpaceResponse response) { if (response != null && response.spaces != null) { spaces = response.spaces; if (spaces != null && spaces.Count > 0 && spaces[0].assetBundleRoomId != null) { selectedSpaceUrl = spaces[0].assetBundleRoomId.url; } else { Debug.LogWarning("No available spaces or assetBundleRoomId is null."); selectedSpaceUrl = null; // or some fallback } Debug.Log("Spaces loaded: " + spaces.Count); } else { showError("خطا", "بارگذاری فضاها با خطا مواجه شد"); } } public void showError(string title, string description) { CancelInvoke("hideError"); gameObject.transform.position = GameObject.FindGameObjectWithTag("anocher").transform.position; gameObject.transform.rotation = GameObject.FindGameObjectWithTag("anocher").transform.rotation; Error.SetActive(true); Error.transform.Find("error/title").GetComponentInChildren().text = title; Error.transform.Find("error/description").GetComponentInChildren().text = description; Invoke("hideError", 6); } public void hideError() { Error.SetActive(false); } internal void Print(string j) { print(j); } }