void Update() { VCEMath.DrawTarget dtar; if (VCEInput.s_MouseOnUI) { m_Center = InvalidPos; } else { if (VCEMath.RayCastDrawTarget(VCEInput.s_PickRay, out dtar, 1)) { m_Center.x = dtar.snapto.x; m_Center.y = dtar.snapto.y; m_Center.z = dtar.snapto.z; } else { m_Center = InvalidPos; } } }
void KeyFocus() { if ((Input.GetKeyDown(KeyCode.F) || VCEInput.s_RightDblClick) && !UICamera.inputHasFocus && !Input.GetMouseButton(0) && !s_ProtectLock0) { VCEMath.DrawTarget dtar; if (VCEMath.RayCastDrawTarget(VCEInput.s_PickRay, out dtar, VCEMath.MC_ISO_VALUE)) { Vector3 newtar = (dtar.snapto.ToVector3() + dtar.cursor.ToVector3() + Vector3.one) * 0.5f * s_Scene.m_Setting.m_VoxelSize; // New look distance to keep the origin distance VCECamera cam_scr = m_MainCamera.GetComponent <VCECamera>(); float dist = cam_scr.Distance; // Maximum distance float maxdist = s_Scene.m_Setting.m_VoxelSize * 10.0f; if (dist > maxdist) { dist = maxdist; } cam_scr.SetTarget(newtar); cam_scr.SetDistance(dist); } } }
// Update is called once per frame void Update() { if (!VCEditor.DocumentOpen() || VCEditor.SelectedVoxelType < 0 || VCEInput.s_MouseOnUI) { m_GizmoGroup.gameObject.SetActive(false); return; } // Cancel if (VCEInput.s_Cancel) { Cancel(); } if (VCEInput.s_Shift && VCEInput.s_Left) { m_Offset = m_Offset - IntVector3.UnitX; } if (VCEInput.s_Shift && VCEInput.s_Right) { m_Offset = m_Offset + IntVector3.UnitX; } if (VCEInput.s_Shift && VCEInput.s_Up) { m_Offset = m_Offset + IntVector3.UnitY; } if (VCEInput.s_Shift && VCEInput.s_Down) { m_Offset = m_Offset - IntVector3.UnitY; } if (VCEInput.s_Shift && VCEInput.s_Forward) { m_Offset = m_Offset + IntVector3.UnitZ; } if (VCEInput.s_Shift && VCEInput.s_Back) { m_Offset = m_Offset - IntVector3.UnitZ; } float voxel_size = VCEditor.s_Scene.m_Setting.m_VoxelSize; m_CursorGizmoCube.m_VoxelSize = voxel_size; m_OffsetGizmoCube.m_VoxelSize = voxel_size; if (VCEMath.RayCastDrawTarget(VCEInput.s_PickRay, out m_Target, VCEMath.MC_ISO_VALUE)) { m_GizmoGroup.gameObject.SetActive(true); IntVector3 draw = m_Target.cursor + m_Offset; m_CursorGizmoCube.transform.position = m_Target.cursor.ToVector3() * voxel_size; m_OffsetGizmoCube.transform.position = draw.ToVector3() * voxel_size; bool cursor_in = VCEditor.s_Scene.m_IsoData.IsPointIn(m_Target.cursor); bool offset_in = VCEditor.s_Scene.m_IsoData.IsPointIn(draw); bool show_offset = (m_Offset.ToVector3().magnitude > 0.1f); m_CursorGizmoCube.gameObject.SetActive(cursor_in && show_offset); m_OffsetGizmoCube.gameObject.SetActive(offset_in); if (cursor_in && offset_in && Input.GetMouseButtonDown(0)) { Do(); } } else { m_GizmoGroup.gameObject.SetActive(false); } }
void Update() { // Common draw target VCEMath.RayCastDrawTarget(VCEInput.s_PickRay, out m_Target, 1, true); // Inspector if (VCEditor.s_Scene.m_IsoData.m_Voxels.Count > 0) { ShowMainInspector(); } else { HideMainInspector(); } // Cancel if (VCEInput.s_Cancel) { #if CAN_CANCELALLMETHOD if (m_MethodExec == null) { m_SelectionMgr.ClearSelection(); } else { m_MainInspector.GetComponent <VCEUISelectVoxelInspector>().CancelAllMethod(); } #else m_SelectionMgr.ClearSelection(); #endif } // Execute selection method if (m_MethodExec != null) { m_MethodExec.MainMethod(); if (m_MethodExec.m_NeedUpdate) { m_SelectionMgr.RebuildSelectionBoxes(); m_MethodExec.m_NeedUpdate = false; } } else { VCEditor.Instance.m_NearVoxelIndicator.enabled = false; } if (!m_MainInspector.activeInHierarchy) { m_MainInspector.GetComponent <VCEUISelectVoxelInspector>().Update(); } if (m_SelectionMgr.m_Selection.Count > 0) { if (VCEInput.s_Shift && VCEInput.s_Left) { ExtrudeSelection(-1, 0, 0); VCEStatusBar.ShowText("Extrude left".ToLocalizationString(), 2); } if (VCEInput.s_Shift && VCEInput.s_Right) { ExtrudeSelection(1, 0, 0); VCEStatusBar.ShowText("Extrude right".ToLocalizationString(), 2); } if (VCEInput.s_Shift && VCEInput.s_Up) { ExtrudeSelection(0, 1, 0); VCEStatusBar.ShowText("Extrude up".ToLocalizationString(), 2); } if (VCEInput.s_Shift && VCEInput.s_Down) { ExtrudeSelection(0, -1, 0); VCEStatusBar.ShowText("Extrude down".ToLocalizationString(), 2); } if (VCEInput.s_Shift && VCEInput.s_Forward) { ExtrudeSelection(0, 0, 1); VCEStatusBar.ShowText("Extrude forward".ToLocalizationString(), 2); } if (VCEInput.s_Shift && VCEInput.s_Back) { ExtrudeSelection(0, 0, -1); VCEStatusBar.ShowText("Extrude back".ToLocalizationString(), 2); } } // Tips if (!Input.GetMouseButton(0) && VCEditor.s_Scene.m_IsoData.IsPointIn(m_Target.snapto)) { tips_counter -= Time.deltaTime; } }
void Update() { if (VCEditor.SelectedPart == null) { return; } if (VCEInput.s_Cancel) { Cancel(); return; } if (VCEditor.SelectedPart != m_LastSelectedPart) { if (m_PartInst != null) { GameObject.Destroy(m_PartInst); } if (VCEditor.SelectedPart.m_ResObj == null) { Debug.LogError("This part has no prefab resource: " + VCEditor.SelectedPart.m_Name); Cancel(); return; } m_PartInst = GameObject.Instantiate(VCEditor.SelectedPart.m_ResObj) as GameObject; m_PartInst.SetActive(false); m_PartInst.transform.parent = this.transform; m_PartInst.transform.localPosition = Vector3.zero; m_Tool = m_PartInst.GetComponent <VCEComponentTool>(); m_Tool.m_IsBrush = true; m_Tool.m_InEditor = true; m_Tool.m_ToolGroup.SetActive(true); Collider[] cs = m_PartInst.GetComponentsInChildren <Collider>(true); foreach (Collider c in cs) { if (c.gameObject != m_Tool.m_ToolGroup.gameObject) { Collider.Destroy(c); } else { c.enabled = false; } } m_LastSelectedPart = VCEditor.SelectedPart; } float voxel_size = VCEditor.s_Scene.m_Setting.m_VoxelSize; if (!VCEInput.s_MouseOnUI && VCEMath.RayCastDrawTarget(VCEInput.s_PickRay, out m_Target, VCEMath.MC_ISO_VALUE) && VCEditor.s_Scene.m_IsoData.IsPointIn(m_Target.cursor)) { m_PartInst.SetActive(true); Vector3 point = m_Target.rch.point * 2; IntVector3 ipoint = new IntVector3(point); m_Tool.SetPivotPos(ipoint.ToVector3() * 0.5f * voxel_size); bool canput = true; if (VCEditor.s_Scene.m_IsoData.FindComponentsAtPos(m_PartInst.transform.localPosition).Count > 0) { canput = false; } // Mirror if (VCEditor.s_Mirror.Enabled_Masked) { VCEditor.s_Mirror.CalcPrepare(VCEditor.s_Scene.m_Setting.m_VoxelSize); if (m_PartInst.transform.localPosition.x == VCEditor.s_Mirror.WorldPos.x && VCEditor.s_Mirror.XPlane_Masked) { canput = false; } if (m_PartInst.transform.localPosition.y == VCEditor.s_Mirror.WorldPos.y && VCEditor.s_Mirror.YPlane_Masked) { canput = false; } if (m_PartInst.transform.localPosition.z == VCEditor.s_Mirror.WorldPos.z && VCEditor.s_Mirror.ZPlane_Masked) { canput = false; } } if (canput) { m_Tool.m_SelBound.m_BoundColor = GLComponentBound.s_Green; m_Tool.m_SelBound.m_Highlight = false; } else { m_Tool.m_SelBound.m_BoundColor = GLComponentBound.s_Red; m_Tool.m_SelBound.m_Highlight = true; } if (Input.GetMouseButtonDown(0) && canput) { Do(); } } else { m_PartInst.SetActive(false); } }
// Update is called once per frame protected void Update() { if (!VCEditor.DocumentOpen() || VCEditor.SelectedVoxelType < 0) { m_Phase = EPhase.Free; m_GizmoCube.gameObject.SetActive(false); return; } float voxel_size = VCEditor.s_Scene.m_Setting.m_VoxelSize; m_GizmoCube.m_VoxelSize = voxel_size; ExtraAdjust(); if (m_Phase == EPhase.Free) { if (!VCEInput.s_MouseOnUI) { // Cancel if (VCEInput.s_Cancel) { ResetDrawing(); Cancel(); } VCEMath.RayCastDrawTarget(VCEInput.s_PickRay, out m_Target, VCEMath.MC_ISO_VALUE); if (VCEditor.s_Scene.m_IsoData.IsPointIn(m_Target.cursor)) { m_GizmoCube.CubeSize = IntVector3.One; m_GizmoCube.transform.position = m_Target.cursor.ToVector3() * voxel_size; m_GizmoCube.gameObject.SetActive(true); if (Input.GetMouseButtonDown(0)) { m_Begin = new IntVector3(m_Target.cursor); m_End = new IntVector3(m_Target.cursor); m_Phase = EPhase.DragPlane; VCEditor.Instance.m_UI.DisableFunctions(); VCEditor.s_ProtectLock0 = true; VCEStatusBar.ShowText("Drag an area".ToLocalizationString(), 2); } } else { m_GizmoCube.gameObject.SetActive(false); } } else { m_GizmoCube.gameObject.SetActive(false); } VCEditor.Instance.m_NearVoxelIndicator.enabled = true; } else if (m_Phase == EPhase.DragPlane) { // Cancel if (VCEInput.s_Cancel) { ResetDrawing(); } RaycastHit rch; if (VCEMath.RayCastCoordPlane(VCEInput.s_PickRay, ECoordPlane.XZ, m_Begin.y, out rch)) { m_End = new IntVector3(Mathf.FloorToInt(rch.point.x), m_Begin.y, Mathf.FloorToInt(rch.point.z)); VCEditor.s_Scene.m_IsoData.ClampPointI(m_End, m_Begin.x < 0.5f * VCEditor.s_Scene.m_IsoData.m_HeadInfo.xSize); m_PointBeforeAdjustHeight = rch.point; VCEditor.s_Scene.m_IsoData.ClampPointI(m_End, m_Begin.x < 0.5f * VCEditor.s_Scene.m_IsoData.m_HeadInfo.xSize); m_GizmoCube.CubeSize = Size; m_GizmoCube.transform.position = Min.ToVector3() * voxel_size; } else { ResetDrawing(); } if (Input.GetMouseButtonUp(0)) { m_Phase = EPhase.AdjustHeight; VCEStatusBar.ShowText("Adjust height".ToLocalizationString(), 2); } VCEditor.Instance.m_NearVoxelIndicator.enabled = false; } else if (m_Phase == EPhase.AdjustHeight) { // Cancel if (VCEInput.s_Cancel) { ResetDrawing(); } float height = m_PointBeforeAdjustHeight.y; VCEMath.RayAdjustHeight(VCEInput.s_PickRay, m_PointBeforeAdjustHeight, out height); m_End.y = Mathf.FloorToInt(height + 0.3f); VCEditor.s_Scene.m_IsoData.ClampPointI(m_End); m_GizmoCube.CubeSize = Size; m_GizmoCube.transform.position = Min.ToVector3() * voxel_size; // Do the brush if (Input.GetMouseButtonDown(0)) { m_Phase = EPhase.Drawing; Do(); VCEStatusBar.ShowText("Done".ToLocalizationString(), 2); } VCEditor.Instance.m_NearVoxelIndicator.enabled = false; } }