/// <summary> /// Tries to rotate the tile that is behind mouse position. /// </summary> /// <param name="degrees">the degree value the tile will be rotated by.</param> private void TryToRotateTile(int degrees) { GameObject hitObject = VMEGlobal.GetTileAtMousePosition(); if (hitObject != null) { hitObject.transform.Rotate(new Vector3(0, degrees, 0)); } }
public override void Input(SceneView sceneView) { base.Input(sceneView); searchWindow.Input(sceneView); Event e = Event.current; if (e.isKey) { if (e.keyCode == KeyCode.I) { GameObject target = VMEGlobal.GetTileAtMousePosition(); if (target != null) { SetSwatchSelection(target); } } } }
public void PaintAtHoverPosition() { //Get GameObject that we hovered over to check if we can paint, //also use its rotation for the new tile. GameObject hoveredTile = VMEGlobal.GetTileAtMousePosition(); //if theres none. if (hoveredTile == null) { Debug.LogWarning("[Paint Mode]: Not hovered over a tile, thereby can't paint a tile."); } else { //Get selected item in Swatch. GameObject selectedSwatchItem = voxelSwatchReference.GetSelectedTile(); //Get position next to hovered tile. Vector3 newPosition = VMEGlobal.GetPositionNextToHoveredTile(); //Paint the tile. VMEMainWindow.Instance.tileAddControls.PaintTIle(selectedSwatchItem, hoveredTile, newPosition); } }
/// <summary> /// Tries to switch the tile to another style of that tile. /// </summary> private void TryToSwitchTileStyle() { //Get the tile i'm pointing at. GameObject target = VMEGlobal.GetTileAtMousePosition(); if (target == null) { Debug.LogWarning("[Edit Mode - SwapStyle]: No target selected."); } else { VSTileGroup group = voxelSwatchReference.GetSwatch().GetGroupByName(target.name); if (group == null) { Debug.LogWarning("[Edit Mode - SwapStyle]: This tile is not a item from the VoxelSwatch. Style swap not possible."); } else { GameObject[] itemsInGroup = group.styles.ToArray(); if (itemsInGroup.Length == 1) { Debug.LogWarning("[Edit Mode - SwapStyle]: The Tile of type: " + target.name + " Only has one variation."); } else { int currentIndexInGroup = -1; Debug.Log("Items in the group: " + itemsInGroup.Length); for (int i = 0; i < itemsInGroup.Length; i++) { if (target.name == itemsInGroup[i].name) { currentIndexInGroup = i; Debug.Log(currentIndexInGroup); } } int newIndex = -1; if (currentIndexInGroup != -1) { Debug.Log(currentIndexInGroup + " : " + itemsInGroup.Length); if (currentIndexInGroup + 1 == itemsInGroup.Length) { newIndex = 0; } else { newIndex = currentIndexInGroup + 1; } if (currentIndexInGroup != newIndex) { VMEMainWindow.Instance.tileAddControls.EditTile(itemsInGroup[newIndex].gameObject, target); } } } } } }