var abPath = "prefab/character/nanjianshi_01all.unity3d";
var assetName = "Nanjianshi_01All";
LuaHelper.GetResManager().LoadPrefabAsync(abPath, assetName, CreateModel);
public bool LoadPrefabAsync(string abPath, string assetName, LoadPrefabAsyncCallBack lpac=null)
{
//lpac = lpacallFunc;
// lpacb = lpacallFunc;
#if UNITY_EDITOR
string abname = abPath;
LoadPrefabSync(abPath, assetName, 1, null, false);
if (lpac != null) {
lpac(abname);
return true;
}
#endif
if (!prefabs.ContainsKey(abPath))
{
LoadBundleAsync(abPath, assetName, false, lpac);
}
else if (lpac != null)
{
lpac(abPath);
}
return false;
}
public bool LoadPrefabSync(string abPath, string assetName, int poolSize, Transform parent, bool dontDestroy = false)
{
string abName = abPath;
string[] nameArray = abPath.Split('/');
if (nameArray.Length == 0)
{
return false;
}
if (!prefabs.ContainsKey(abName))
{
GameObject obj = LoadAsset<GameObject>(abName, assetName, dontDestroy);
prefabs.Add(abName, obj);
OldGameObjectPool pool = new OldGameObjectPool();
bool trueInact = true;
if (abPath.StartsWith("prefab")) trueInact = false;
if (abPath == "ui/prefab/map/luxiandian") trueInact = false;
pool.Initialize(obj, parent, poolSize, trueInact);
pools[obj] = pool;
//if (LuaHelper.GetResManager().CanDestroy(abPath))
// LuaHelper.GetResManager().UnLoadAssetBundle(abPath, false);
}
return true;
}
void CreateModel(string str)
{
var go = LuaHelper.GetResManager().CreateGoInstance(str);
go.transform.SetParent(RolePoint.transform);
go.transform.localScale = Vector3.one * 16;
go.transform.localEulerAngles = Vector3.zero;
go.transform.localPosition = Vector3.zero;
LUA_SetLayerIncludeChildren(go, "UI");
LUA_AnimationPlay(go, "Idle01"); // Idle01
}