private void RebuildDrone(Drone drone) { MetaDroneData metaData = allowedDrones.Find(x => drone.GetType() == x.droneType); if (metaData == null) { return; } GameObject newDrone = MakeDrone(metaData); newDrone.GetComponent <DroneUI>().realDrone = drone; Instantiate(metaData.creator(uiElements)).transform.SetParent(newDrone.transform); }
private void MakeNewDrone() { string drone_name = drone_selector.options[drone_selector.value].text; MetaDroneData metaData = allowedDrones.Find(x => x.name.Equals(drone_name)); GameObject droneUI = MakeDrone(metaData); GameObject droneCreator = Instantiate(metaData.creator(uiElements)); droneCreator.transform.SetParent(droneUI.transform); GameObject newDrone = Instantiate(droneCreator.GetComponent <ComponentCreator>().objectTemplate); newDrone.transform.parent = droneTemplates; droneUI.GetComponent <DroneUI>().realDrone = newDrone.GetComponent <Drone>(); }