public void Initialize() { planetColor = new Color(30f / 255f, 147f / 255f, 45f / 255f); MainGame game = GameObject.Find("MainGameLoop").GetComponent <MainGame>(); planetMaterial = game.materialManager.planetMaterial; waterMaterial = game.materialManager.waterMaterial; atmosphereMaterial = game.materialManager.atmosphereMaterial; shapeGenerator = transform.gameObject.AddComponent <ShapeGenerator>(); shapeGenerator.Initiliaze(); if (meshFilters == null || meshFilters.Length == 0) { meshFilters = new MeshFilter[6]; } textureFaces = new TextureFace[6]; Vector3[] directions = { Vector3.up, Vector3.down, Vector3.left, Vector3.right, Vector3.forward, Vector3.back }; for (int i = 0; i < 6; i++) { GameObject meshObj = new GameObject("face " + i); meshObj.transform.parent = transform; meshObj.AddComponent <MeshRenderer>(); meshFilters[i] = meshObj.AddComponent <MeshFilter>(); meshFilters[i].sharedMesh = new Mesh(); meshFilters[i].GetComponent <MeshRenderer>().sharedMaterial = planetMaterial; textureFaces[i] = meshObj.AddComponent <TextureFace>(); textureFaces[i].Initialize(shapeGenerator, meshObj, meshFilters[i].sharedMesh, resolution, directions[i], this, i); } GeneratePlanet(); }