示例#1
0
        /// 创建面板
        IEnumerator StartCreatePanel(string name, AssetBundle bundle, LuaFunction func = null)
        {
            name += "Panel";
            GameObject prefab = Util.LoadAsset(bundle, name);

            yield return(new WaitForEndOfFrame());

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

            go.name                    = name;
            go.layer                   = LayerMask.NameToLayer("Default");
            go.transform.parent        = Parent;
            go.transform.localScale    = Vector3.one;
            go.transform.localPosition = Vector3.zero;

            yield return(new WaitForEndOfFrame());

            go.AddComponent <LuaBehaviour>().OnInit(bundle);

            if (func != null)
            {
                func.Call(go);
            }
            Debug.Log("StartCreatePanel------>>>>" + name);
        }
示例#2
0
        internal string PreLoadObject(string prefabName, bool isLocal = false, int poolSize = 1)
        {
            isLocal = true;
            GameObject tmp = null;
            string     key = prefabName.Split('/')[prefabName.Split('/').Length - 1];

            //if (!m_GameObjectPools.ContainsKey(key))
            if (m_spawnPool.prefabs.ContainsKey(key) == false)
            {
                if (GameStart.Instance.IsDebug || isLocal)
                {
                    tmp = UnityEditor.AssetDatabase.LoadAssetAtPath("Assets/" + prefabName + ".prefab", typeof(GameObject)) as GameObject;
                    //tmp = Resources.Load<GameObject>(prefabName);
                }
                else
                {
                    AssetBundle bundle = ResManager.LoadBundle(key);
                    tmp = Util.LoadAsset(bundle, key);
                }
                if (tmp == null)
                {
                    Debug.LogError("资源:" + prefabName + " 加载为空");
                }
                else if (!prefabName.StartsWith("Prefabs/FirstPackage") && !prefabName.StartsWith("Prefabs/SecondPackage"))
                {
                    CreatePrefabPool(tmp.transform);
                    //CreatePool(key, poolSize, 10, tmp);
                }
            }
            return(key);
        }
示例#3
0
 /// <summary>
 /// 获取一个GameObject资源
 /// </summary>
 /// <param name="name"></param>
 public GameObject LoadAsset(string name)
 {
     if (bundle == null)
     {
         return(null);
     }
     return(Util.LoadAsset(bundle, name));
 }