/* This method gets created when a platform or individual tile gets generated for the first time * It created a GameObject called "Map", which holds all platforms and individual tiles **/ Platform CreatePlatform(string platformName) { if(string.IsNullOrEmpty(platformName)) // Check if the name is set, otherwise give it one { platformName = "Platform" + tiles.GetNumberOfPlatforms(); } var platformObject = new GameObject(); // new platform platformObject.name = platformName; // name it platformObject.transform.parent = tiles.transform; // make the map to its parent platformObject.AddComponent<Platform>(); // add the script to the platform Platform platform = platformObject.GetComponent<Platform>(); // get the platform script platform.Setup(); // Tell the platform to setup itself tiles.AddPlatform(platform); // add it to the tilesFolder return platform; }