Esempio n. 1
0
 public bool IsRepainting()
 {
     return(m_GUIWrapper.IsRepainting());
 }
Esempio 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);
            }
        }
Esempio n. 3
0
 public bool CanRepaint()
 {
     return(m_GUIWapper.IsRepainting());
 }