public void OnInstalledObjectCreated(InstalledObject obj) { GameObject instObj = new GameObject(); _installedObjectGameObjectMap.Add(obj, instObj); instObj.name = obj.ObjectType + "_" + obj.Tile.X + "_" + obj.Tile.Y; instObj.transform.position = new Vector3(obj.Tile.X + (obj.Width - 1) / 2f, obj.Tile.Y + (obj.Height - 1) / 2f, 0); instObj.transform.SetParent(this.transform, true); if (obj.ObjectType == "Door") { Tile north = _world.GetTileAt(obj.Tile.X, obj.Tile.Y + 1); Tile south = _world.GetTileAt(obj.Tile.X, obj.Tile.Y - 1); if (north != null && south != null && north.InstalledObject != null && south.InstalledObject != null && north.InstalledObject.ObjectType == "Wall" && south.InstalledObject.ObjectType == "Wall") { instObj.transform.rotation = Quaternion.Euler(0, 0, 90); } } instObj.AddComponent <SpriteRenderer>().sprite = GetSpriteForInstalledObject(obj); instObj.GetComponent <SpriteRenderer>().sortingLayerName = "InstalledObjects"; //instObj.GetComponent<SpriteRenderer>().color = obj.Tint; obj.RegisterOnInstalledObjectChangedCallback(OnInstalledObjectChanged); }