private void OnEditModeChanged(EditorInteractionLogic.EditMode mode) { this.mode = mode; switch (mode) { case EditorInteractionLogic.EditMode.None: newBlockRenderer.enabled = false; selectedBlockData = null; newBlockFilter.mesh = null; colliderClickBroadcaster.LayerMask &= ~(1 << LayerMask.NameToLayer("Block")); if (currentDeleteHovered != null) { currentDeleteHovered.material = new Material(Shader.Find("Diffuse")); } break; case EditorInteractionLogic.EditMode.Insert: newBlockRenderer.enabled = true; break; case EditorInteractionLogic.EditMode.Delete: colliderClickBroadcaster.LayerMask |= (1 << LayerMask.NameToLayer("Block")); break; } }
public DeleteBlockCommand(GameObject block, StageEditorState stageState) { EditorBlockData data = block.GetComponent <EditorBlockData_SceneInstance>().Data; OrthoAngle angle = block.transform.eulerAngles.y.ToOrthoAngle(); rect = data.GetGridRect( new Vector2(block.transform.position.x, block.transform.position.z), angle == OrthoAngle.Ninety || angle == OrthoAngle.TwoSeventy); blockObject = block; blockMesh = block.GetComponent <MeshFilter>().mesh; this.stageState = stageState; }
/// <summary> /// Creates a command to place a block at the given location and rotation. /// </summary> /// <param name="blockData">Describes the block being placed.</param> /// <param name="atLocation">The location to place the block at.</param> /// <param name="rotation">The rotation of this block.</param> /// <param name="stageState">The persistent stage state object.</param> public PlaceBlockCommand(EditorBlockData blockData, Vector3 atLocation, OrthoAngle rotation, StageEditorState stageState) { this.blockData = blockData; this.atLocation = atLocation; this.rotation = rotation; this.stageState = stageState; // Calculate the rect that this block will effect. rect = blockData.GetGridRect( new Vector2(atLocation.x, atLocation.z), rotation == OrthoAngle.Ninety || rotation == OrthoAngle.TwoSeventy); // Create a new instance for this command. spawnedInstance = new GameObject { layer = LayerMask.NameToLayer("Block") }; // Allow future commands to access this block data. spawnedInstance.AddComponent <EditorBlockData_SceneInstance>().Data = blockData; }
private void OnNewPieceSelected(EditorBlockData data) { selectedBlockData = data; newBlockFilter.sharedMesh = data.mesh; selectionSize = data.size; }