Пример #1
0
    private IEnumerator starLoaderResouce()
    {
        string resname = _appInfo.folderName != "" ? _appInfo.folderName + "/" + _appInfo.appName : _appInfo.appName;

        prefabAssetLoadAgent = ResourceMgr.LoadAssetFromeAssetsFolderFirst(ResourcesPath.UIPrefabPath, resname, "prefab", typeof(UnityEngine.Object), null);
        while (!prefabAssetLoadAgent.IsDone)
        {
            yield return(null);
        }
        if (prefabAssetLoadAgent.AssetObject == null)
        {
            Debug.LogError("Load UI Root Faild!");
            yield break;
        }
        GameObject obj = (GameObject)prefabAssetLoadAgent.AssetObject;

        isLoaderComplete(obj);
    }
Пример #2
0
    protected static void CreateSingleton(string parentFolderPath, string resourceName)
    {
        agent = ResourceMgr.LoadAssetFromeAssetsFolderFirst(parentFolderPath, resourceName, "prefab",
                                                            typeof(GameObject), a =>
        {
            Debug.LogFormat("load monosingle prefab ,prefab name:{0}", resourceName);

            var prefab = (GameObject)a.AssetObject;

            if (prefab == null)
            {
                CreateSingleton();
                return;
            }
            var trans  = CreatePrefab(prefab, typeof(T).Name, GetRootTrans());
            s_instance = trans.gameObject.GetComponent <T>() ?? trans.gameObject.AddComponent <T>();

            //agent.Release();
        });
    }
Пример #3
0
    private AssetLoadAgent uiRootloadAgent = null; // uiroot的加载代理


    public IEnumerator InitUI(Action action)
    {
        Debug.LogError("-------initUI ----1---");
        uiRootloadAgent = ResourceMgr.LoadAssetFromeAssetsFolderFirst(ResourcesPath.UIPrefabPath,
                                                                      (string)UI_STAGE, "prefab", typeof(UnityEngine.Object), null);

        while (!uiRootloadAgent.IsDone)
        {
            yield return(null);
        }

        if (uiRootloadAgent.AssetObject == null)
        {
            Debug.LogError("Load UI Root Faild!");
            yield break;
        }

        Debug.LogError("-------initUI ----2---");
        Transform stageTrans = ((GameObject)Instantiate(uiRootloadAgent.AssetObject)).transform;

        stageTrans.gameObject.name = UI_STAGE;
        stageTrans.parent          = CachedTrans;

        //> 创建界面面板
        UIRootTransform = new GameObject("UIContainers").transform;
        //> 设置在主界面下
        UIRootTransform.parent           = stageTrans;
        UIRootTransform.localScale       = Vector3.one;
        UIRootTransform.gameObject.layer = stageTrans.gameObject.layer;
        //> Z坐标不要放太远,会影响3D模型动作计算,导致模型抖动
        transform.position = new Vector3(0, 100, 0);
        Debug.LogError("-------initUI ----3---");

        if (action != null)
        {
            action();
        }
    }