Exemplo n.º 1
0
        public bool DoSelectBone(out int id, out bool additive)
        {
            id       = 0;
            additive = false;

            if (IsActionTriggering(SkeletonAction.Select))
            {
                id       = m_HoveredBoneID;
                additive = m_GUIWrapper.isActionKeyDown;

                if (mode == SkeletonMode.Selection)
                {
                    m_GUIWrapper.UseCurrentEvent();
                    m_GUIWrapper.SetGuiChanged(true);
                }

                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        public void OnGUI()
        {
            m_ControlID = m_GUIWrapper.GetControlID(kBrushHashCode, FocusType.Passive);

            var eventType = m_GUIWrapper.eventType;

            if (!m_GUIWrapper.isAltDown)
            {
                m_GUIWrapper.LayoutControl(controlID, 0f);
            }

            if (isActivable)
            {
                m_SliderData.position = m_GUIWrapper.GUIToWorld(m_GUIWrapper.mousePosition);

                if (m_GUIWrapper.IsMouseDown(0))
                {
                    m_DeltaAcc = 0f;
                    onStrokeBegin(this);
                    onStrokeStep(this);
                    m_GUIWrapper.SetGuiChanged(true);
                }

                if (eventType == EventType.MouseMove)
                {
                    onMove(this);
                    m_GUIWrapper.UseCurrentEvent();
                }

                if (m_GUIWrapper.isShiftDown && eventType == EventType.ScrollWheel)
                {
                    var sizeDelta = HandleUtility.niceMouseDeltaZoom * kWheelSizeSpeed;
                    size = Mathf.Max(1f, size + sizeDelta);
                    onSize(this);
                    m_GUIWrapper.UseCurrentEvent();
                }
            }

            if (isHot && m_GUIWrapper.IsMouseUp(0))
            {
                onStrokeEnd(this);
            }

            if (m_GUIWrapper.IsRepainting() && (isHot || isActivable))
            {
                onRepaint(this);
            }

            Vector3 position;

            if (m_GUIWrapper.DoSlider(m_ControlID, m_SliderData, out position))
            {
                step = Mathf.Max(step, 1f);

                var delta     = position - m_SliderData.position;
                var direction = delta.normalized;
                var magnitude = delta.magnitude;

                m_SliderData.position -= direction * m_DeltaAcc;

                m_DeltaAcc += magnitude;

                if (m_DeltaAcc >= step)
                {
                    var stepVector = direction * step;

                    while (m_DeltaAcc >= step)
                    {
                        m_SliderData.position += stepVector;

                        onMove(this);
                        onStrokeStep(this);

                        m_DeltaAcc -= step;
                    }
                }

                m_SliderData.position = position;
                onStrokeDelta(this);
            }
        }