コード例 #1
0
ファイル: NodeManager.cs プロジェクト: yclooc/UGCFramework
    static Node CreateNode(string nodePath, Action finishCallback = null)
    {
        if (string.IsNullOrEmpty(nodePath))
        {
            return(null);
        }

        Node node = GetNode(nodePath);

        if (node)
        {
            node.transform.SetAsLastSibling();
            node.Open();
        }
        else
        {
            AssetBundle ab = null;
            if (File.Exists(ConstantUtils.AssetBundleFolderPath + "/common/sprite/" + MiscUtils.GetFileName(nodePath)))
            {
                ab = BundleManager.Instance.GetSpriteBundle(MiscUtils.GetFileName(nodePath));
            }
            string     path = "nodes/" + nodePath;
            GameObject go   = BundleManager.Instance.GetGameObject(path, PageManager.Instance.CurrentPage.name);
            if (go)
            {
                node = go.GetComponent <Node>();
                node.SetSpriteAB(ab);
                node.nodePath = nodePath;
                node.Init();
                UIUtils.AttachAndReset(go, PageManager.Instance.CurrentPage.transform);
                go.transform.SetAsLastSibling();
                node.Open();
            }
            else
            {
                Debug.Log("错误! 找不到路径: " + path);
            }
        }
        if (finishCallback != null)
        {
            finishCallback();
        }
        return(node);
    }
コード例 #2
0
ファイル: NodeManager.cs プロジェクト: nianyang111/testclient
    static Node CreateNode(string nodeName, Action finishCallback = null)
    {
        if (string.IsNullOrEmpty(nodeName))
        {
            return(null);
        }

        Node node = GetNode(nodeName);

        if (node)
        {
            node.transform.SetAsLastSibling();
            node.Open();
        }
        else
        {
            string     path = "nodes/" + nodeName;
            GameObject go   = BundleManager.Instance.GetGameObject(path, PageManager.Instance.CurrentPage.name);
            if (go)
            {
                node          = go.GetComponent <Node>();
                node.nodeName = nodeName;
                node.Init();
                UIUtils.AttachAndReset(go, PageManager.Instance.CurrentPage.transform);
                go.transform.SetAsLastSibling();
                node.Open();
            }
            else
            {
                Debug.LogError("错误! 找不到路径: " + path);
            }
        }
        if (finishCallback != null)
        {
            finishCallback();
        }
        return(node);
    }
コード例 #3
0
ファイル: PageManager.cs プロジェクト: nianyang111/testclient
    /// <summary>
    /// 创建一个新的特定类型的Page
    /// </summary>
    /// <param name="pageName"></param>
    /// <returns></returns>
    Page CreatePage(string pageName)
    {
        if (string.IsNullOrEmpty(pageName))
        {
            return(null);
        }
        if (CurrentPage != null && pageName == CurrentPage.name)
        {
            return(null);
        }

        Page page = GetComponentInChildren <Page>(true);

        if (page == null || page.name != pageName)
        {
            AssetBundle ab = BundleManager.Instance.GetSpriteBundle("mainpic", MiscUtils.GetFileName(pageName));
            if (ab != null)
            {
                spriteABList.Add(ab);
            }
            string     path = "pages/" + pageName;
            GameObject go   = BundleManager.Instance.GetGameObject(path, MiscUtils.GetFileName(pageName));
            if (go)
            {
                UIUtils.AttachAndReset(go, transform);
                page = go.GetComponent <Page>();
                page.InitData(ab);
            }
            else
            {
                TipManager.Instance.OpenTip(TipType.SimpleTip, "加载界面失败");
                return(null);
            }
        }
        page.transform.SetAsFirstSibling();
        return(page);
    }