using UnityEngine; public class MegaPointCacheInstance : MonoBehaviour { [HideInInspector] public MegaPointCache mod; [HideInInspector] public MegaModifyObject modobj; public GameObject obj; [HideInInspector] public Mesh mesh; public float time; public float speed = 1f; public int updateRate; public int frame; public bool recalcNorms = true; public bool recalcBounds = true; public void SetSource(GameObject srcobj) { if ((bool)srcobj) { if (this.mesh == null) { this.mesh = MegaUtils.GetMesh(base.gameObject); } Mesh mesh = MegaUtils.GetMesh(srcobj); if (mesh.vertexCount == this.mesh.vertexCount) { obj = srcobj; mod = srcobj.GetComponent(); modobj = srcobj.GetComponent(); this.mesh = MegaUtils.GetMesh(base.gameObject); } } } private void Update() { if (!mod || !modobj || !mesh) { return; } time += Time.deltaTime * speed; frame--; if (frame < 0) { frame = updateRate; mod.ModifyInstance(modobj, time); mesh.vertices = mod.sverts; if (recalcNorms) { mesh.RecalculateNormals(); } if (recalcBounds) { mesh.RecalculateBounds(); } } } }