public static CelestialBody Create(FileInfo file) { CelestialBodyLoader loader = new CelestialBodyLoader(); if (loader.Load(file)) { UnityEngine.Object prefab = Resources.Load(CelestialBodyLoader.PrefabPath + loader.m_Name, typeof(GameObject)); if (null != prefab) { GameObject gameObject = UnityEngine.Object.Instantiate(prefab) as GameObject; if (null != gameObject) { gameObject.name = loader.m_Name; if (loader.m_Type == "Planet") { CelestialPlanet newPlanet = gameObject.AddComponent <CelestialPlanet>(); if (null != newPlanet) { if (newPlanet.Initialize(loader)) { return(newPlanet); } } } else if (loader.m_Type == "Ship") { CelestialShip newShip = gameObject.AddComponent <CelestialShip>(); if (null != newShip) { if (newShip.Initialize(loader)) { return(newShip); } } } else if (loader.m_Type == "Moon") { CelestialMoon newMoon = gameObject.AddComponent <CelestialMoon>(); if (null != newMoon) { if (newMoon.Initialize(loader)) { return(newMoon); } } } } } } return(null); }