public void LoadFile(string name) { string json = File.ReadAllText(SetFullPath(name)); ObjectData[] loadedData = JsonHelper.FromJson <ObjectData>(json); if (AppManager.singleton) { AppManager.singleton.DestroyAllObjects(); } foreach (ObjectData o in loadedData) { switch (o.objectType) { case 0: print("Loading wall"); Wall newWall = Instantiate(AppManager.singleton.wallPrefab).GetComponent <Wall>(); newWall.Construct(o.position, o.rotation, o.color, o.selected, o.startPoint, o.endPoint, o.width); newWall.SetColliders(); AppManager.singleton.objects.Add(newWall); break; case 1: Furniture newFurniture = Instantiate(FurnitureTool.singleton.furniturePrefab).GetComponent <Furniture>(); newFurniture.Construct(o.position, o.rotation, o.scale, o.color, o.selected, o.spriteIndex); newFurniture.Place(); AppManager.singleton.objects.Add(newFurniture); break; case 2: Door newDoor = Instantiate(DoorTool.singleton.doorPrefab).GetComponent <Door>(); newDoor.Construct(o.position, o.rotation, o.scale, o.color, o.selected, o.spriteIndex); newDoor.Place(); AppManager.singleton.objects.Add(newDoor); break; } } }