public EffectItem addEffItem(string id, string path, int effType = 0, Transform effcon = null) { removeEffItem(id); float t; effData d = null; if (!dLifeTime.ContainsKey(path)) { SXML xml = XMLMgr.instance.GetSXML("effect.eff", "id==" + id); if (xml == null) { return(null); } d = new effData(); d.path = xml.getString("file"); d.lifetime = xml.getInt("lenth") / 10; dLifeTime[path] = d; } else { d = dLifeTime[path]; } t = d.lifetime; if (effType == TYPE_LOOP) { t = -1; } if (dEffectItem.ContainsKey(id)) { dEffectItem[id].dispose(); } EffectItem item = new EffectItem(id, d.path, t); dEffectItem[id] = item; if (effcon == null) { item.setParent(con); } else { item.setParent(effcon); } return(item); }
private void getGameObject(string id, Action <GameObject> handle) { bool flag = id == "" || id == null; if (!flag) { bool flag2 = !this.dLifeTime.ContainsKey(id); if (flag2) { Variant effectConf = GraphManager.singleton.getEffectConf(id); bool flag3 = effectConf == null; if (flag3) { return; } effData value = default(effData); value.path = effectConf["file"]; value.lifetime = effectConf["lenth"]._float / 10f; this.dLifeTime[id] = value; } string path = this.dLifeTime[id].path; bool flag4 = !MapEffMgr.dGo.ContainsKey(id); if (flag4) { IAsset asset = os.asset.getAsset <IAssetParticles>(path, delegate(IAsset ast) { GameObject assetObj = (ast as AssetParticlesImpl).assetObj; MapEffMgr.dGo[id] = assetObj; GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(assetObj); gameObject2.transform.SetParent(this.con, false); handle(gameObject2); }, null, delegate(IAsset ast, string err) { Debug.LogError("加载特效失败" + id); }); (asset as AssetImpl).loadImpl(false); } else { bool flag5 = MapEffMgr.dGo[id] != null; if (flag5) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(MapEffMgr.dGo[id]); gameObject.transform.SetParent(this.con, false); handle(gameObject); } } } }
private void getGameObject(string id, Action <GameObject> handle) { if (id == "" || id == null) { return; } if (!dLifeTime.ContainsKey(id)) { Variant va = GraphManager.singleton.getEffectConf(id); if (va == null) { return; } effData d = new effData(); d.path = va["file"]; d.lifetime = va["lenth"]._float / 10; dLifeTime[id] = d; } string path = dLifeTime[id].path; if (!dGo.ContainsKey(id)) { IAsset res_mesh = os.asset.getAsset <IAssetParticles>(path, (IAsset ast) => { GameObject res_obj = (ast as AssetParticlesImpl).assetObj; dGo[id] = res_obj; GameObject the_obj = GameObject.Instantiate(res_obj) as GameObject; the_obj.transform.SetParent(con, false); handle(the_obj); }, null, (IAsset ast, string err) => { //加载失败 Debug.LogError("加载特效失败" + id); }); (res_mesh as AssetImpl).loadImpl(false); } else if (dGo[id] != null) { GameObject the_obj = GameObject.Instantiate(dGo[id]) as GameObject; the_obj.transform.SetParent(con, false); handle(the_obj); } }