コード例 #1
0
        public override void ProcessEvents(Event e)
        {
            base.ProcessEvents(e);

            if (ViewRect.Contains(e.mousePosition))
            {
                if (e.button == 0)
                {
                    if (e.type == EventType.MouseDown)
                    {
                    }

                    if (e.type == EventType.MouseDrag)
                    {
                    }

                    if (e.type == EventType.MouseUp)
                    {
                    }
                }

                if (e.button == 1)
                {
                    if (e.type == EventType.MouseDown)
                    {
                        MousePosition = e.mousePosition;
                        NodeToDelete  = null;
                        if (CurrentGraph != null)
                        {
                            NodeToDelete = CurrentGraph.Nodes.FirstOrDefault(x => x.NodeRect.Contains(e.mousePosition));
                        }

                        if (NodeToDelete == null)
                        {
                            ProcessContextMenu(e, 0);
                        }
                        else
                        {
                            ProcessContextMenu(e, 1);
                        }
                    }
                }
            }
        }
コード例 #2
0
        private void HighlightGUI()
        {
            if (HighlightTF && (
                    Event.current.type == EventType.MouseMove ||
                    (Event.current.type == EventType.MouseDrag && Event.current.button == 0) ||
                    Event.current.type == EventType.MouseUp ||
                    Event.current.type == EventType.ScrollWheel ||
                    Event.current.type == EventType.MouseDown
                    ))
            {
                HoveringVoxelPosition = null;

                if (!ViewRect.Contains(Event.current.mousePosition))
                {
                    if (HighlightTF.gameObject.activeSelf)
                    {
                        HighlightTF.gameObject.SetActive(false);
                        Repaint();
                    }
                    return;
                }

                ViewCastHit((hit) => {
                    string hitName = hit.transform.name;

                    if (hitName == "Cube")
                    {
                        // Cube
                        HighlightTF.gameObject.SetActive(true);
                        HighlightTF.position   = hit.point;
                        HighlightTF.localScale = hit.transform.localScale * 0.5f;
                        HighlightTF.rotation   = Quaternion.LookRotation(-hit.normal);
                        Repaint();
                    }
                    else if (IsRigging)
                    {
                        if (PaintingBoneIndex == -1 || CurrentBrushType == BrushType.Rect)
                        {
                            if (HighlightTF.gameObject.activeSelf)
                            {
                                HighlightTF.gameObject.SetActive(false);
                                Repaint();
                            }
                        }
                        else
                        {
                            // Editing Bone
                            if (hitName == "Voxel")
                            {
                                HighlightTF.gameObject.SetActive(true);
                                HighlightTF.position   = hit.transform.position;
                                HighlightTF.localScale = hit.transform.localScale;
                                HighlightTF.rotation   = Quaternion.LookRotation(-hit.normal);
                                HoveringVoxelPosition  = hit.transform.parent.localPosition;
                                HoveredVoxelPosition   = HoveringVoxelPosition;
                                Repaint();
                            }
                            else if (hitName == "Box")
                            {
                                HighlightTF.gameObject.SetActive(true);
                                int maxAxis    = Util.MaxAxis(hit.normal);
                                Vector3 offset = ContainerTF.position;
                                var newPos     = new Vector3(
                                    Mathf.Round(hit.point.x - offset.x) + offset.x,
                                    Mathf.Round(hit.point.y - offset.y) + offset.y,
                                    Mathf.Round(hit.point.z - offset.z) + offset.z
                                    );
                                newPos[maxAxis]        = hit.point[maxAxis];
                                HighlightTF.position   = newPos;
                                HighlightTF.localScale = Vector3.one;
                                HighlightTF.rotation   = Quaternion.LookRotation(-hit.normal);
                                HoveringVoxelPosition  = HighlightTF.localPosition - ContainerTF.localPosition;
                                HoveredVoxelPosition   = HoveringVoxelPosition;
                                Repaint();
                            }
                            else
                            {
                                if (HighlightTF.gameObject.activeSelf)
                                {
                                    HighlightTF.gameObject.SetActive(false);
                                    Repaint();
                                }
                            }
                        }
                    }
                    else
                    {
                        if (HighlightTF.gameObject.activeSelf)
                        {
                            HighlightTF.gameObject.SetActive(false);
                            Repaint();
                        }
                    }
                }, () => {
                    if (HighlightTF.gameObject.activeSelf)
                    {
                        HighlightTF.gameObject.SetActive(false);
                        Repaint();
                    }
                });
            }
        }