void Awake() { SpringGrid prefabGrid = WavePrefab.GetComponent <SpringGrid>(); if (prefabGrid == null) { throw new Exception("WaveManager::Start: WavePrefab has no SpringGrid component"); } // Get data for the grid mesh MeshFilter filter = WavePrefab.GetComponent <MeshFilter>(); if (filter == null) { throw new Exception("WaveManager::Start: WavePrefab has no Mesh component"); } MeshIndices = SpringGrid.ImportMesh(filter.sharedMesh); // Allocate some shared temporary space Vector3[] tempPositions = new Vector3[SpringGrid.kGridHeight * SpringGrid.kGridWidth]; Color[] tempColors = new Color[SpringGrid.kGridHeight * SpringGrid.kGridWidth]; // Spawn the grids Grids = new SpringGrid[kNumSegments]; for (int i = 0; i < kNumSegments; ++i) { GameObject gridObj = GameObject.Instantiate(WavePrefab); gridObj.transform.SetParent(transform, false); SpringGrid grid = gridObj.GetComponent <SpringGrid>(); grid.Theta = i * SpringGrid.kThetaDelta; grid.Initialize(MeshIndices, tempPositions, tempColors); Grids[i] = grid; } // Link all the grids together for (int i = 0; i < kNumSegments - 1; ++i) { Grids[i].LinkRight(Grids[i + 1]); } Grids[kNumSegments - 1].LinkRight(Grids[0]); }