#if UNITY_EDITOR using System; using UguiToolkit.Editor; using UnityEditor; using UnityEngine; namespace UguiToolkit { public class GlobalManager { private static GlobalManager m_instance; public static GlobalManager Instance { get { if (m_instance == null) { m_instance = new(); } return m_instance; } } public SettingScriptObject setting; public CacheScriptObject cache; public PanelCache GetCache(GameObject asset, bool isVertical = false) { if (cache.panelCaches.TryGetValue(asset, out var allDirectionPanelCache)) { if (isVertical) return allDirectionPanelCache.panelCacheOfVertical; else return allDirectionPanelCache.panelCacheOfHorizontal; } return null; } public void SaveCache(GameObject asset, PanelCache panelCache) { if (!cache.panelCaches.TryGetValue(asset, out var allDirectionPanelCache)) { cache.panelCaches[asset] = new AllDirectionPanelCache(); } if (panelCache.isVertical) cache.panelCaches[asset].panelCacheOfVertical = panelCache; else cache.panelCaches[asset].panelCacheOfHorizontal = panelCache; SaveCache(); } public void SaveCache() { EditorUtility.SetDirty(cache); AssetDatabase.SaveAssetIfDirty(cache); } } } #endif