/// <summary> /// 创建对象 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="assetName"></param> /// <param name="onCreate"></param> public void LoadGameObject(StateItem itemInfo, OnLoadItemEvent onLoad) { if (_cansaleKeys.Contains(itemInfo.ID)) { _cansaleKeys.RemoveAll(x => x == itemInfo.ID); } if (!_loadingKeys.Contains(itemInfo.ID)) { _loadingKeys.Add(itemInfo.ID); var bInfo = itemInfo as BundleStateItem; var pInfo = itemInfo as PrefabStateItem; if (bInfo != null) { LoadGameObject(bInfo, onLoad); } else if (pInfo != null) { LoadGameObject(pInfo, onLoad); } } }
/// <summary> /// 获取对象实例 /// </summary> private GameObject CreateInstance(GameObject prefab, StateItem trigger) { if (_cansaleKeys.Contains(trigger.ID)) { _cansaleKeys.Remove(trigger.ID); return(null); } if (prefab == null || trigger == null) { return(null); } GameObject go = GameObject.Instantiate(prefab); go.SetActive(true); if (trigger.reset) { go.transform.localPosition = trigger.position; go.transform.localEulerAngles = trigger.rotation; } return(go); }