public void ShowWidget() { foreach (var item in widgets) { UIWidgetController.Show(item); } }
public static GameObject Show(Transform parent, string path, GameEvent evt) { GameObject gameObject = null; if (widgets.ContainsKey(path)) { widgets.TryGetValue(path, out gameObject); } if (gameObject == null) { gameObject = GameObjectManager.GetInstance().CreateObject(path); } gameObject.transform.SetParent(parent); RectTransform rectTransform = gameObject.transform as RectTransform; rectTransform.anchoredPosition3D = Vector3.zero; rectTransform.localScale = Vector3.one; rectTransform.sizeDelta = Vector2.zero; UIWidgetController uIWidgetController = gameObject.GetComponent <UIWidgetController>(); if (uIWidgetController == null) { uIWidgetController = gameObject.AddComponent <UIWidgetController>(); } uIWidgetController.path = path; uIWidgetController.evt = evt; gameObject.name = path; widgets[path] = gameObject; return(gameObject); }
public static void Hide(GameObject gameObject) { UIWidgetController uIWidgetController = gameObject.GetComponent <UIWidgetController>(); gameObject.SendMessage("OnHide", SendMessageOptions.DontRequireReceiver); //将对象存储 GameObjectManager.GetInstance().StoreObject(gameObject, "UI/" + uIWidgetController.path); widgets.Remove(gameObject.name); uIWidgetController.evt = new GameEvent(0); }
private void OnDestroy() { foreach (var widget in widgets) { UIWidgetController.Hide(widget); } GameObjectManager manager = GameObjectManager.GetInstance(); if (preLoad != null) { foreach (var item in preLoad) { manager.ClearObject(item.name); } } Resources.UnloadUnusedAssets(); }
public static void Register(string path, int showCode, int hideCode) { UIWidgetController.RegisterWidget(path, showCode, hideCode); }