void OnSelectionChange() { s_LastCreate = null; if (m_Selection.Count == 1) { VCComponentData sel_data = m_Selection[0].m_Component.m_Data; VCPartData sel_part_data = sel_data as VCPartData; VCDecalData sel_decal_data = sel_data as VCDecalData; if (sel_part_data != null) { ShowDataInspector(VCConfig.s_PartTypes[sel_part_data.m_Type].m_InspectorRes, sel_data); } else if (sel_decal_data != null) { ShowDataInspector("GUI/Prefabs/Inspectors/Components Inspectors/inspector decal image", sel_data); } } if (m_Selection.Count > 0) { VCEStatusBar.ShowText(m_Selection.Count.ToString() + " " + "component(s)".ToLocalizationString() + " " + "selected".ToLocalizationString(), 4); } }
void UpdateMirror() { if (Instance.m_UI.m_PartTab.isChecked) { if (SelectedPart != null) { s_Mirror.m_Mask = (byte)SelectedPart.m_MirrorMask; } else { VCESelectComponent sel = null; foreach (VCEBrush brush in SelectedBrushes) { if (brush is VCESelectComponent) { sel = brush as VCESelectComponent; break; } } if (sel != null) { if (sel.m_Selection.Count == 0) { s_Mirror.m_Mask = 7; } else { int mask = 7; foreach (VCESelectComponent.SelectInfo si in sel.m_Selection) { VCPartData part = si.m_Component.m_Data as VCPartData; if (part != null) { mask &= (VCConfig.s_Parts[part.m_ComponentId].m_MirrorMask); } } s_Mirror.m_Mask = (byte)mask; } } else { s_Mirror.m_Mask = 7; } } } else if (Instance.m_UI.m_MaterialTab.isChecked) { s_Mirror.m_Mask = 7; } else if (Instance.m_UI.m_PaintTab.isChecked) { s_Mirror.m_Mask = 7; } else if (Instance.m_UI.m_DecalTab.isChecked) { s_Mirror.m_Mask = 7; } else { s_Mirror.m_Mask = 0; } }
void Update() { if (!VCEditor.DocumentOpen()) { return; } // Check 's_LastCreate' if (s_LastCreate != null) { ClearSelection(); SelectInfo si = new SelectInfo(); si.m_Component = s_LastCreate; m_Selection.Add(si); OnSelectionChange(); } VCEditor.s_ProtectLock0 = UsingGizmo; NormalizeSelection(); // Update Pick Order Vector3 mousePos = Input.mousePosition; if ((mousePos - lastMousePos).magnitude > 3.1f) { pick_order = 0; lastMousePos = mousePos; } #region PART_DESC // Part Description Board if (m_DescBoard != null) { m_DescBoard.m_Position = Vector3.Lerp(m_DescBoard.m_Position, VCEInput.s_PickRay.GetPoint(1.5f), 0.5f); List <VCEComponentTool> pickall = new List <VCEComponentTool> (); if (!UsingGizmo && !VCEInput.s_MouseOnUI) { pickall = VCEMath.RayPickComponents(VCEInput.s_PickRay); } List <VCPart> pps = new List <VCPart> (); Vector3 v = Vector3.zero; if (pickall.Count > 0) { v = pickall[0].transform.localPosition; } foreach (VCEComponentTool ct in pickall) { if (Vector3.Distance(ct.transform.localPosition, v) > VCEditor.s_Scene.m_Setting.m_VoxelSize * 2) { continue; } VCPart pp = ct.GetComponent <VCPart>(); if (pp != null) { pps.Add(pp); } } if (pickall.Count > 0) { m_DescBoard.FadeIn(); VCEditor.Instance.m_UI.m_HoloBoardCamera.enabled = true; } else { VCEditor.Instance.m_UI.m_HoloBoardCamera.enabled = false; m_DescBoard.FadeOut(); } pickall.Clear(); VCEditor.Instance.m_UI.m_PartDescList.SyncList(pps); pps.Clear(); pickall = null; pps = null; } #endregion // Pick Component VCEComponentTool picked = null; if (!VCEInput.s_MouseOnUI && !m_MouseOnGizmo) { picked = VCEMath.RayPickComponent(VCEInput.s_PickRay, pick_order); } if (Input.GetMouseButtonDown(0) && !VCEInput.s_MouseOnUI && !m_MouseOnGizmo) { if (!VCEInput.s_Shift && !VCEInput.s_Control && !VCEInput.s_Alt) { m_Selection.Clear(); } if (picked != null) { SelectInfo si = FindSelected(picked); if (si != null) { m_Selection.Remove(si); } else { si = new SelectInfo(); si.m_Component = picked; List <SelectInfo> del_list = new List <SelectInfo> (); foreach (SelectInfo sel in m_Selection) { VCEComponentTool ct = sel.m_Component; List <VCEComponentTool> images = MirrorImage(ct); if (images.Contains(si.m_Component)) { del_list.Add(sel); } } m_Selection.Add(si); foreach (SelectInfo del in del_list) { m_Selection.Remove(del); } } pick_order++; } OnSelectionChange(); } // Update bound color & highlight foreach (VCComponentData cd in VCEditor.s_Scene.m_IsoData.m_Components) { VCEComponentTool c = cd.m_Entity.GetComponent <VCEComponentTool>(); c.m_SelBound.enabled = true; c.m_SelBound.GetComponent <Collider>().enabled = true; c.m_SelBound.m_Highlight = (c == picked); c.m_SelBound.m_BoundColor = GLComponentBound.s_Blue; } // Update selection and mirror's bound color if (m_Selection.Count > 0) { VCEditor.s_Mirror.CalcPrepare(VCEditor.s_Scene.m_Setting.m_VoxelSize); foreach (SelectInfo si in m_Selection) { VCEComponentTool c = si.m_Component; List <VCEComponentTool> mirrors = MirrorImage(c); foreach (VCEComponentTool m in mirrors) { m.m_SelBound.m_BoundColor = GLComponentBound.s_Orange; } } foreach (SelectInfo si in m_Selection) { VCEComponentTool c = si.m_Component; c.m_SelBound.m_BoundColor = GLComponentBound.s_Yellow; } } // Update Inspectors if (m_Selection.Count < 1) { HideInspectors(); } else if (m_Selection.Count == 1) { ShowMainInspector(); VCEUISelectComponentInspector sci = m_MainInspector.GetComponent <VCEUISelectComponentInspector>(); if (m_Selection[0].m_Component != null) { sci.m_SelectInfo.text = m_Selection[0].m_Component.gameObject.name; } else { sci.m_SelectInfo.text = "< Deleted >"; } } else { ShowMainInspector(); HideDataInspector(); VCEUISelectComponentInspector sci = m_MainInspector.GetComponent <VCEUISelectComponentInspector>(); sci.m_SelectInfo.text = m_Selection.Count.ToString() + " " + "objects".ToLocalizationString() + " " + "selected".ToLocalizationString(); } // Transform Gizmos if (m_Selection.Count > 0) { Vector3 avePos = Vector3.zero; int rotmask = 7; foreach (SelectInfo si in m_Selection) { avePos += si.m_Component.transform.position; VCPartData part_data = si.m_Component.m_Data as VCPartData; if (part_data != null) { rotmask &= VCConfig.s_PartTypes[si.m_Component.m_Data.m_Type].m_RotateMask; } } avePos /= ((float)m_Selection.Count); m_MovingGizmo.transform.position = avePos; m_RotatingGizmo.transform.position = avePos; m_MovingGizmo.gameObject.SetActive(VCEditor.TransformType == EVCETransformType.Move); m_RotatingGizmo.gameObject.SetActive(VCEditor.TransformType == EVCETransformType.Rotate); m_RotatingGizmo.m_AxisMask = rotmask; } else { m_MovingGizmo.gameObject.SetActive(false); m_RotatingGizmo.gameObject.SetActive(false); } }