// Use this for initialization void Start() { GameObject effectPrefab = (GameObject)AssetDatabase.LoadAssetAtPath(mEffectPrefabPathName, typeof(GameObject)); for (int i = 0; i < mEffectInstanceNum; ++i) { mEffectInstanceArray[i] = GameObject.Instantiate(effectPrefab) as GameObject; mEffectInstanceArray[i].transform.position = Random.insideUnitSphere; mEffectInstanceArray[i].transform.rotation = Random.rotationUniform; } ParticleSystem[] psArray = mEffectInstanceArray[0].GetComponentsInChildren <ParticleSystem>(); foreach (ParticleSystem ps in psArray) { SubEffectInfo info = new SubEffectInfo(); info.mName = ps.name; info.mNum = 0; info.mSize = 0.0f; mSubEffectInfoList.Add(info); } mFrames = 0; mLastInterval = Time.realtimeSinceStartup; mCount = 0; }
// Update is called once per frame void Update() { while (mTime > mInterval && mIndex <= mEffectPerformanceDataList.Count) { if (null != gameObject.GetComponent <SingleEffectPerformance>()) { SingleEffectPerformance comp = gameObject.GetComponent <SingleEffectPerformance>(); mEffectPerformanceDataList[mIndex - 1].mAverageParticleNum = comp.GetAverageParticleNum(); mEffectPerformanceDataList[mIndex - 1].mAverageParticleSize = comp.GetAverageParticleSize(); mEffectPerformanceDataList[mIndex - 1].mAverageFPS = comp.GetAverageFPS(); List <SubEffectInfo> infos = comp.GetSubEffectInfoList(); for (int i = 0; i < infos.Count; ++i) { SubEffectInfo info = new SubEffectInfo(); info.CopyFrom(infos[i]); mEffectPerformanceDataList[mIndex - 1].mSubEffectInfoList.Add(info); } comp.DestroyGameObjects(); GameObject.DestroyImmediate(comp, true); System.GC.Collect(); //Debug.Log("Average FPS : " + comp.GetAverageFPS()); } if (mIndex == mEffectPerformanceDataList.Count) { ++mIndex; break; } SingleEffectPerformance sep = gameObject.AddComponent <SingleEffectPerformance>(); sep.mEffectPrefabPathName = mEffectPerformanceDataList[mIndex].mPathFileName; mTime = 0.0f; ++mIndex; } if (mIndex > mEffectPerformanceDataList.Count) { mFinish = true; } mTime += Time.deltaTime; }
public void CopyFrom(SubEffectInfo info) { mName = info.mName; mNum = info.mNum; mSize = info.mSize; }