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); } }
void Update() { if (VCEditor.SelectedDecalGUID == 0) { return; } if (VCEditor.SelectedDecalIndex < 0) { return; } if (VCEditor.SelectedDecal == null) { return; } if (VCEInput.s_Cancel) { Cancel(); return; } m_DecalInst.m_Guid = VCEditor.SelectedDecalGUID; float voxel_size = VCEditor.s_Scene.m_Setting.m_VoxelSize; RaycastHit rch; if (!VCEInput.s_MouseOnUI && VCEMath.RayCastVoxel(VCEInput.s_PickRay, out rch, VCEMath.MC_ISO_VALUE)) { AdjustBrush(); m_DecalInst.gameObject.SetActive(true); Vector3 point = rch.point * 2; IntVector3 ipoint = new IntVector3(point); m_Tool.SetPivotPos(ipoint.ToVector3() * 0.5f * voxel_size); m_DecalInst.transform.localRotation = Quaternion.LookRotation(-rch.normal); m_DecalInst.transform.Rotate(-rch.normal, m_RotateAngle, Space.World); bool canput = true; List <VCComponentData> poscdatas = VCEditor.s_Scene.m_IsoData.FindComponentsAtPos(m_DecalInst.transform.localPosition, VCDecalData.s_ComponentId); foreach (VCComponentData cd in poscdatas) { VCDecalData ddata = cd as VCDecalData; if (ddata != null) { if (ddata.m_Guid == m_DecalInst.m_Guid) { canput = false; break; } } } // Mirror if (VCEditor.s_Mirror.Enabled_Masked) { VCEditor.s_Mirror.CalcPrepare(VCEditor.s_Scene.m_Setting.m_VoxelSize); if (m_DecalInst.transform.localPosition.x == VCEditor.s_Mirror.WorldPos.x && VCEditor.s_Mirror.XPlane_Masked) { canput = false; } if (m_DecalInst.transform.localPosition.y == VCEditor.s_Mirror.WorldPos.y && VCEditor.s_Mirror.YPlane_Masked) { canput = false; } if (m_DecalInst.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_DecalInst.gameObject.SetActive(false); } }