using System.Collections; using System.Collections.Generic; using UnityEngine; public class ViewManager2 { private class ViewCacheInfo { public string fullPath; public GameObject gameObject; } private static List _ViewCacheInfos = new(); public static void ShowView(string path) { string fullPath = "SmartBow/Prefabs/Views/" + path; _DestroyExistViews(fullPath); GameObject o = Object.Instantiate(Resources.Load(fullPath)); ViewCacheInfo viewCacheInfo = new ViewCacheInfo(); viewCacheInfo.fullPath = fullPath; viewCacheInfo.gameObject = o; _ViewCacheInfos.Add(viewCacheInfo); } public static void HideView(string path) { string fullPath = "SmartBow/Prefabs/Views/" + path; _DestroyExistViews(fullPath); } private static void _DestroyExistViews(string fullPath) { _ViewCacheInfos.FindAll(e => e.fullPath == fullPath).ForEach(e => { if (e.gameObject) Object.Destroy(e.gameObject); }); _ViewCacheInfos.RemoveAll(e => e.fullPath == fullPath); } public const string Path_SettingsView = "Home/SettingsView"; }