コード例 #1
0
 public void ShowWidget()
 {
     foreach (var item in widgets)
     {
         UIWidgetController.Show(item);
     }
 }
コード例 #2
0
    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);
    }
コード例 #3
0
    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);
    }
コード例 #4
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();
    }
コード例 #5
0
 public static void Register(string path, int showCode, int hideCode)
 {
     UIWidgetController.RegisterWidget(path, showCode, hideCode);
 }