private void ClearOrganModels() { if (m_listOrganModels == null) { return; } foreach (GameObject OrganModel in m_listOrganModels) { GameObjectOperation.ClearMaterials(OrganModel, 0f); GameObjectOperation.ClearMeshes(OrganModel); GameObject.Destroy(OrganModel); } m_listOrganModels.Clear(); }
/// <summary> /// 更新该帧内的对象 /// </summary> private void UpdateGameObject(GameObject preGameObject, GameObject curGameObject, List <Vector3> veticesFragment, WormholeFragment wormholeFragment) { if (m_AnimationIndex < m_AnimationMaxIndex) { /* * 若该片段为NULL或该片段的个数为0 * 则说明该对象无顶点 * 不继续进行计算 */ if (!GameObjectValidate.HavaVertices(preGameObject) || veticesFragment == null) { return; //09-05 } //09-05 if (veticesFragment.Count != 0) { Vector3[] vertices = GameObjectOperation.GetVertices(preGameObject); /* * 根据片段中记录的顶点偏移数据 * 计算对象在该帧移动后的位置 * 其中该片段记录的是世界坐标系下的数据 * 因此要转换成对象所在的局部坐标系下 */ for (int i = 0; i < vertices.Length; i++) { vertices[i] += veticesFragment[i]; } /* * 更新该对象 * 防止渲染出现异常 */ GameObjectOperation.UpdateMeshInfo(preGameObject, vertices); } /* * 虫洞逐帧变化模拟 * 当阈值增量为0,说明不变化 * 当阈值增量不为0 * 开启虫洞模拟 (_SimWormhole的值为1),并赋予相应的阈值 */ if (wormholeFragment.ThresholdDetla == 0) { return; } Material material = GameObjectOperation.GetMaterial(preGameObject); if (material == null || material.shader.name != "Custom/Leaves") { return; } material.SetFloat("_SimWormhole", 1); material.SetColor("_Threshold", CellularTexture.DEC2Color(wormholeFragment.InitThreshold + (int)(wormholeFragment.ThresholdDetla * m_AnimationIndex)) ); } else //最后一帧 { /* * 无需计算 * 只需设置前一关键帧的对象不可见 * 后一帧对象可见即可 */ preGameObject.SetActive(false); curGameObject.SetActive(true); GameObjectOperation.ClearMaterials(preGameObject); GameObjectOperation.ClearMeshes(preGameObject); GameObject.Destroy(preGameObject); } }