Ejemplo n.º 1
0
    public GameObject LoadUI(string prefabPath, IElementCenter elementCenter, GameObject parentUI = null)
    {
        if (string.IsNullOrEmpty(prefabPath))
        {
            Debug.LogError("prefabPath is null");
            return(null);
        }

        var go = CreateGameObjectFromPrefab(prefabPath);

        if (go == null)
        {
            Debug.LogError("UI in path:" + prefabPath + " cannot be load.");
            return(null);
        }

        var scanner = go.GetComponent <IElementScanner>();

        if (scanner != null)
        {
            scanner.Scan(go, elementCenter);
        }

        if (parentUI == null)
        {
            parentUI = elementCenter.Get(UI_ROOT_ELEMENT_ID) as GameObject;
        }

        if (parentUI == null)
        {
            Debug.LogError("no rootUI loaded, please load rootUI first.");
        }
        else
        {
            concreteUIManager.AddChildUI(go, parentUI);
        }

        return(go);
    }
Ejemplo n.º 2
0
    public void LoadUI(UINode uiNode, GameObject parentUI = null)
    {
        Debug.Log("Load UINode:" + uiNode.Prefab);
        GameObject ui = UIManager.LoadUI(uiNode.Prefab, elementCenter, parentUI);

        if (uiNode.Children != null && uiNode.Children.Count > 0)
        {
            GameObject parent = ui;
            foreach (var c in uiNode.Children)
            {
                if (c.ParentElementId != null)
                {
                    var tmp = elementCenter.Get(c.ParentElementId) as GameObject;
                    if (tmp != null)
                    {
                        parent = tmp;
                    }
                }
                LoadUI(c.Prefab, parent);
            }
        }
    }
Ejemplo n.º 3
0
    public GameObject LoadUI(string prefabPath, IElementCenter elementCenter, GameObject parentUI = null)
    {
        if (string.IsNullOrEmpty(prefabPath))
        {
            Debug.LogError("prefabPath is null");
            return null;
        }

        var go = CreateGameObjectFromPrefab(prefabPath);

        if (go == null)
        {
            Debug.LogError("UI in path:" + prefabPath + " cannot be load.");
            return null;
        }

        var scanner = go.GetComponent<IElementScanner>();
        if (scanner != null)
        {
            scanner.Scan(go, elementCenter);
        }

        if (parentUI == null)
        {
            parentUI = elementCenter.Get(UI_ROOT_ELEMENT_ID) as GameObject;
        }

        if (parentUI == null)
        {
            Debug.LogError("no rootUI loaded, please load rootUI first.");
        }
        else
        {
            concreteUIManager.AddChildUI(go, parentUI);
        }

        return go;
    }