public WorldToScreenElement Add(GameObject uiPrefab, Transform anchorTransform, Vector3 offset) { GameObject instanceObject = Instantiate(uiPrefab, _visibleGameObject.transform); WorldToScreenElement uiElement = new WorldToScreenElement(instanceObject.transform, anchorTransform, offset); _handledTransforms.Add(uiElement); return(uiElement); }
public void OnPlacementPositionFound(object cityToPlaceObject) { ThreadsafePlaceable cityToPlace = (ThreadsafePlaceable)cityToPlaceObject; CityPlaceable city = GameObject.Instantiate((CityPlaceable)cityToPlace.MapPlaceable, cityToPlace.Position, Quaternion.identity); Debug.Log("City placed at: " + cityToPlace.Position); if (!_placementController.PlaceObject(city)) { GameObject.Destroy(city.gameObject); return; } _placedCities.Add(city); WorldToScreenElement uiGameObject = _worldToScreenManager.Add( cityWorldToScreenView.gameObject, city.gameObject.transform, new Vector3(0, 50f, 0)); CityWorldToScreenView worldToScreenView = uiGameObject.UiTransform.gameObject.GetComponent <CityWorldToScreenView>(); worldToScreenView.City = city; }
public void Remove(WorldToScreenElement worldUiObject) { _handledTransforms.Remove(worldUiObject); Destroy(worldUiObject.UiTransform.gameObject); Destroy(worldUiObject.AnchorTransform.gameObject); }