/// <summary> /// 全屏时,w,h无效 /// </summary> public HeroPhoto(ref RawImage image, int resId, PhotoType type, int w = 2048, int h = 2048, bool bFullScreen = false) { if (Application.isEditor) { image.material.shader = Shader.Find(image.material.shader.name); } Debug.Log("打开玩家展示:" + resId); m_bFullScreen = bFullScreen; if (bFullScreen) { RectTransform rect = image.GetComponent <RectTransform>(); rect.anchorMax = Vector2.one; rect.anchorMin = Vector2.zero; rect.anchoredPosition = Vector2.zero; rect.sizeDelta = Vector2.zero; } m_resId = resId; m_photoImage = image; m_type = type; m_w = w; m_h = h; UIHeroShowEffectCsv showEffectCsv = CsvManager.Inst.GetCsv <UIHeroShowEffectCsv>((int)eAllCSV.eAC_UIHeroShowEffect); m_showEffectData = showEffectCsv.GetData((int)m_resId); OnCreateEnv(); if (type == PhotoType.uieffect) { OnCreateEnterPhoto("born"); } else { // 先加载预加载再创建 if (m_showEffectData == null) { return; } LoadPre(m_showEffectData, () => { if (m_photoObject == null) { return; } OnCreateUI(); OnEnter(); }); } HeroPhotoMgr.Inst.Add(this); }
protected override void _Load() { for (int i = 0; i < m_csv.GetRows(); i++) { UIHeroShowEffectCsvData data = new UIHeroShowEffectCsvData(); data.resId = m_csv.GetIntData(i, (int)eUIHeroShowEffectCsv.resId); data.enterAnimaTime = m_csv.GetFloatData(i, (int)eUIHeroShowEffectCsv.enterAnimaTime); data.enterAnimaName = m_csv.GetData(i, (int)eUIHeroShowEffectCsv.enterAnimaId); data.enterEffectTime = m_csv.GetData(i, (int)eUIHeroShowEffectCsv.enterEffectTime); data.enterEffectId = m_csv.GetData(i, (int)eUIHeroShowEffectCsv.enterEffectId); data.enterSpeakId = m_csv.GetIntData(i, (int)eUIHeroShowEffectCsv.enterHeroSpeakId); data.clickAnimaName = m_csv.GetData(i, (int)eUIHeroShowEffectCsv.clickAnimaId); data.clickEffectId = m_csv.GetIntData(i, (int)eUIHeroShowEffectCsv.clickEffectId); data.idleEffectId = m_csv.GetIntData(i, (int)eUIHeroShowEffectCsv.idleEffectId); data.bz = m_csv.GetData(i, (int)eUIHeroShowEffectCsv.bz); m_dicData.Add(data.resId, data); } }
public void LoadPre(UIHeroShowEffectCsvData data, Action loaded) { List <int> loadPre = new List <int>(); int resId = data.resId; loadPre.Add(resId); EffectCsv effectCsv = CsvManager.Inst.GetCsv <EffectCsv>((int)eAllCSV.eAC_Effect); // 入场特效和声音 string[] effectList = m_showEffectData.enterEffectId.Split('|'); for (int i = 0; i < effectList.Length; i++) { int effectId; int.TryParse(effectList[i], out effectId); EffectCsvData enterEffect = effectCsv.GetData(effectId); if (enterEffect == null) { Debug.LogWarning("英雄展示表配了特效id,但是特效表没有:" + effectId); } else { if (enterEffect.resId != 0) { loadPre.Add(enterEffect.resId); } if (enterEffect.soundId != 0) { loadPre.Add(enterEffect.soundId); } } } // 点击特效和声音 int clickEffect = m_showEffectData.clickEffectId; EffectCsvData eData = effectCsv.GetData(clickEffect); if (eData == null) { Debug.LogWarning("英雄展示表配了特效id,但是特效表没有:" + clickEffect); } else { if (eData.resId != 0) { loadPre.Add(eData.resId); } if (eData.soundId != 0) { loadPre.Add(eData.soundId); } } m_preRes = new Resource[loadPre.Count]; //Debug.Log("预加载数量:" + loadPre.Count); int curPreNum = 0; for (int i = 0; i < loadPre.Count; i++) { Resource tRes = ResourceFactory.Inst.LoadResource(loadPre[i], (res) => { curPreNum++; if (curPreNum == loadPre.Count) { if (loaded != null) { loaded(); } } }); m_preRes[i] = tRes; } }