Exemplo n.º 1
0
        private bool HandleClick(Vector3 localPos, int btn)
        {
            if (LevelEditor.EditState == EditState.Vertices && btn == EditWindowClickDetection.BTN_PRIMARY)
            {
                var ray = EditWindow.GetRayFromMousePosition(localPos);
                //raycast with vertices
                if (Physics.Raycast(ray, out RaycastHit hitInfo, float.MaxValue, vertexLayerMask))
                {
                    var vertex = hitInfo.transform.gameObject.GetComponent <EditableVertex>();
                    if (vertex != null)
                    {
                        Deselect();
                        currentlySelected = hitInfo.transform.gameObject;

                        Gizmo_OLD.Attach(currentlySelected.transform, Vector3.zero);
                        Gizmo_OLD.Visible = true;
                        OnSelected.Invoke(vertex);
                        return(true);
                    }
                }
                else
                {
                    Deselect();
                }
            }
Exemplo n.º 2
0
        void Deselect()
        {
            Gizmo_OLD.Detach();
            Gizmo_OLD.Visible = false;

            if (currentlySelected != null)
            {
                OnDeselected.Invoke(currentlySelected.GetComponent <EditableVertex>());
            }
        }
Exemplo n.º 3
0
        public void Deselect()
        {
            Gizmo_OLD.Detach();
            Gizmo_OLD.Visible = false;

            //place currently selected back into mesh
            if (currentlySelected != null)
            {
                var selectedPrimitive = currentlySelected.GetComponent <EditablePrimitive>();
                var editableMesh      = LevelEditor.CurrentLevel.EditableLevelMesh.GetMaterialMesh(selectedPrimitive.Material);
                editableMesh.AddPrimitive(selectedPrimitive.info);
                editableMesh.UpdateMesh();
                OnDeselected.Invoke(selectedPrimitive);
                Destroy(currentlySelected);
                currentlySelected = null;
            }
        }