コード例 #1
0
        IEnumerator OnLoadAsset(string abname, string assetName, LuaFunction func)
        {
            // Load asset from assetBundle.
            string abName = abname.ToLower() + AppConst.ExtName;
            AssetBundleAssetOperation request = ResourceManager.LoadAssetAsync(abName, assetName, typeof(GameObject));

            if (request == null)
            {
                yield break;
            }
            yield return(StartCoroutine(request));

            // Get the asset.
            GameObject prefab = request.GetAsset <GameObject>();

            if (func != null)
            {
                func.Call(prefab);
                func.Dispose();
                func = null;
            }
        }
コード例 #2
0
        IEnumerator OnCreatePanel(string name, LuaFunction func = null)
        {
            yield return(StartCoroutine(Initialize()));

            string assetName = name + "Panel";
            // Load asset from assetBundle.
            string abName = name.ToLower() + AppConst.ExtName;
            AssetBundleAssetOperation request = ResourceManager.LoadAssetAsync(abName, assetName, typeof(GameObject));

            if (request == null)
            {
                yield break;
            }
            yield return(StartCoroutine(request));

            // Get the asset.
            GameObject prefab = request.GetAsset <GameObject>();

            if (Parent.FindChild(name) != null || prefab == null)
            {
                yield break;
            }
            GameObject go = Instantiate(prefab) as GameObject;

            go.name  = assetName;
            go.layer = LayerMask.NameToLayer("Default");
            go.transform.SetParent(Parent);
            go.transform.localScale    = Vector3.one;
            go.transform.localPosition = Vector3.zero;
            go.AddComponent <LuaBehaviour>();

            if (func != null)
            {
                func.Call(go);
            }
            Debug.LogWarning("CreatePanel::>> " + name + " " + prefab);
        }