Ejemplo n.º 1
0
 private void Press()
 {
     UISystemProfilerApi.AddMarker("Button.onClick", this);
     Sharpness = GameObject.Find("HUD/SharpnessButton");
     Lifesteal = GameObject.Find("HUD/LifestealButton");
     Invoke("sup", 0f);
 }
Ejemplo n.º 2
0
        protected virtual void Set(float input, float input2, bool sendCallback = true)
        {
            // Clamp the input
            float newValue  = ClampValue(input);
            float newValue2 = ClampValue(input2);

            if (newValue2 - newValue < minGap)
            {
                newValue2 = ClampValue(input + minGap);
            }
            // If the stepped value doesn't match the last one, it's time to update
            if (m_Value == newValue && m_Value2 == newValue2)
            {
                return;
            }

            m_Value  = newValue;
            m_Value2 = newValue2;
            UpdateVisuals();
            if (sendCallback)
            {
                UISystemProfilerApi.AddMarker("Slider.value", this);
                m_OnValueChanged.Invoke(newValue, newValue2);
            }
        }
Ejemplo n.º 3
0
        void Set(bool value, bool sendCallback)
        {
            if (m_IsOn == value)
            {
                return;
            }

            // if we are in a group and set to true, do group logic
            m_IsOn = value;
            if (m_Group != null && IsActive())
            {
                if (m_IsOn || (!m_Group.AnyTogglesOn() && !m_Group.allowSwitchOff))
                {
                    m_IsOn = true;
                    m_Group.NotifyToggleOn(this);
                }
            }

            // Always send event when toggle is clicked, even if value didn't change
            // due to already active toggle in a toggle group being clicked.
            // Controls like Dropdown rely on this.
            // It's up to the user to ignore a selection being set to the same value it already was, if desired.
            PlayEffect(toggleTransition == ToggleTransition.None);
            if (sendCallback)
            {
                UISystemProfilerApi.AddMarker("Toggle.value", this);
                onValueChanged.Invoke(m_IsOn);
            }
        }
Ejemplo n.º 4
0
        void Set(float input, bool sendCallback)
        {
            //If our scrollbar is full size we don't have content to scroll
            if (size == 1)
            {
                return;
            }

            float currentValue = m_Value;

            // Clamp the input
            m_Value = Mathf.Clamp01(input);

            // If the stepped value doesn't match the last one, it's time to update
            if (currentValue == value)
            {
                return;
            }

            UpdateVisuals();
            if (sendCallback)
            {
                UISystemProfilerApi.AddMarker("Scrollbar.value", this);
                m_OnValueChanged.Invoke(value);
            }
        }
Ejemplo n.º 5
0
        protected virtual void LateUpdate()
        {
            if (!(bool)((UnityEngine.Object) this.m_Content))
            {
                return;
            }
            this.EnsureLayoutHasRebuilt();
            this.UpdateBounds();
            float   unscaledDeltaTime = Time.unscaledDeltaTime;
            Vector2 offset            = this.CalculateOffset(Vector2.zero);

            if (!this.m_Dragging && (offset != Vector2.zero || this.m_Velocity != Vector2.zero))
            {
                Vector2 anchoredPosition = this.m_Content.anchoredPosition;
                for (int index = 0; index < 2; ++index)
                {
                    if (this.m_MovementType == CHScrollRect.MovementType.Elastic && (double)offset[index] != 0.0)
                    {
                        float currentVelocity = this.m_Velocity[index];
                        anchoredPosition[index] = Mathf.SmoothDamp(this.m_Content.anchoredPosition[index], this.m_Content.anchoredPosition[index] + offset[index], ref currentVelocity, this.m_Elasticity, float.PositiveInfinity, unscaledDeltaTime);
                        if ((double)Mathf.Abs(currentVelocity) < 1.0)
                        {
                            currentVelocity = 0.0f;
                        }
                        this.m_Velocity[index] = currentVelocity;
                    }
                    else if (this.m_Inertia)
                    {
                        this.m_Velocity[index] *= Mathf.Pow(this.m_DecelerationRate, unscaledDeltaTime);
                        if ((double)Mathf.Abs(this.m_Velocity[index]) < 1.0)
                        {
                            this.m_Velocity[index] = 0.0f;
                        }
                        anchoredPosition[index] += this.m_Velocity[index] * unscaledDeltaTime;
                    }
                    else
                    {
                        this.m_Velocity[index] = 0.0f;
                    }
                }
                if (this.m_MovementType == CHScrollRect.MovementType.Clamped)
                {
                    offset            = this.CalculateOffset(anchoredPosition - this.m_Content.anchoredPosition);
                    anchoredPosition += offset;
                }
                this.SetContentAnchoredPosition(anchoredPosition);
            }
            if (this.m_Dragging && this.m_Inertia)
            {
                this.m_Velocity = (Vector2)Vector3.Lerp((Vector3)this.m_Velocity, (Vector3)((this.m_Content.anchoredPosition - this.m_PrevPosition) / unscaledDeltaTime), unscaledDeltaTime * 10f);
            }
            if (this.m_ViewBounds != this.m_PrevViewBounds || this.m_ContentBounds != this.m_PrevContentBounds || this.m_Content.anchoredPosition != this.m_PrevPosition)
            {
                this.UpdateScrollbars(offset);
                UISystemProfilerApi.AddMarker("ScrollRect.value", (UnityEngine.Object) this);
                this.m_OnValueChanged.Invoke(this.normalizedPosition);
                this.UpdatePrevData();
            }
            this.UpdateScrollbarVisibility();
        }
Ejemplo n.º 6
0
        protected override void OnDidApplyAnimationProperties()
        {
            // Has value changed? Various elements of the slider have the old normalisedValue assigned, we can use this to perform a comparison.
            // We also need to ensure the value stays within min/max.
            m_Value = ClampValue(m_Value);
            float oldNormalizedValue = normalizedValue;

            if (m_FillContainerRect != null)
            {
                if (m_FillImage != null && m_FillImage.type == Image.Type.Filled)
                {
                    oldNormalizedValue = m_FillImage.fillAmount;
                }
                else
                {
                    oldNormalizedValue = (reverseValue
                        ? 1 - m_FillRect.anchorMin[(int)axis]
                        : m_FillRect.anchorMax[(int)axis]);
                }
            }
            else if (m_HandleContainerRect != null)
            {
                oldNormalizedValue = (reverseValue
                    ? 1 - m_HandleRect.anchorMin[(int)axis]
                    : m_HandleRect.anchorMin[(int)axis]);
            }

            UpdateVisuals();

            if (oldNormalizedValue != normalizedValue)
            {
                UISystemProfilerApi.AddMarker("Slider.value", this);
                onValueChanged.Invoke(m_Value);
            }
        }
Ejemplo n.º 7
0
        protected override void OnDidApplyAnimationProperties()
        {
            this.m_Value = this.ClampValue(this.m_Value);
            float num = this.normalizedValue;

            if (this.m_FillContainerRect != null)
            {
                if (this.m_FillImage != null && this.m_FillImage.type == Image.Type.Filled)
                {
                    num = this.m_FillImage.fillAmount;
                }
                else
                {
                    num = ((!this.reverseValue) ? this.m_FillRect.anchorMax[(int)this.axis] : (1f - this.m_FillRect.anchorMin[(int)this.axis]));
                }
            }
            else if (this.m_HandleContainerRect != null)
            {
                num = ((!this.reverseValue) ? this.m_HandleRect.anchorMin[(int)this.axis] : (1f - this.m_HandleRect.anchorMin[(int)this.axis]));
            }
            this.UpdateVisuals();
            if (num != this.normalizedValue)
            {
                UISystemProfilerApi.AddMarker("Slider.value", this);
                this.onValueChanged.Invoke(this.m_Value);
            }
        }
Ejemplo n.º 8
0
        protected virtual void LateUpdate()
        {
            if (!m_Content)
            {
                return;
            }

            EnsureLayoutHasRebuilt();
            UpdateBounds();
            float   deltaTime = Time.unscaledDeltaTime;
            Vector2 offset    = CalculateOffset(Vector2.zero);

            if (offset != Vector2.zero || m_Velocity != Vector2.zero)
            {
                Vector2 position = m_Content.anchoredPosition;
                for (int axis = 0; axis < 2; axis++)
                {
                    if (m_Inertia)
                    {
                        m_Velocity[axis] *= Mathf.Pow(m_DecelerationRate, deltaTime);
                        if (Mathf.Abs(m_Velocity[axis]) < 1)
                        {
                            m_Velocity[axis] = 0;
                        }
                        position[axis] += m_Velocity[axis] * deltaTime;
                    }
                    // If we have neither elaticity or friction, there shouldn't be any velocity.
                    else
                    {
                        m_Velocity[axis] = 0;
                    }
                }

                if (m_MovementType == MovementType.Clamped)
                {
                    offset    = CalculateOffset(position - m_Content.anchoredPosition);
                    position += offset;
                }

                SetContentAnchoredPosition(position);
            }

            if (m_Inertia)
            {
                Vector3 newVelocity = (m_Content.anchoredPosition - m_PrevPosition) / deltaTime;
                m_Velocity = Vector3.Lerp(m_Velocity, newVelocity, deltaTime * 10);
            }

            if (m_ViewBounds != m_PrevViewBounds || m_ContentBounds != m_PrevContentBounds || m_Content.anchoredPosition != m_PrevPosition)
            {
                UISystemProfilerApi.AddMarker("ScrollRect.value", this);
                m_OnValueChanged.Invoke(normalizedPosition);
                UpdatePrevData();
            }

            //Moved "UpdateScrollbars" out of the if condition above to fix broken toolbar update
            UpdateScrollbars(offset);
            UpdateScrollbarVisibility();
        }
Ejemplo n.º 9
0
 void Update()
 {
     if (_down)
     {
         UISystemProfilerApi.AddMarker("Button.onDown", this);
         m_OnDown.Invoke();
     }
 }
Ejemplo n.º 10
0
 private void Press()
 {
     if (this.IsActive() && this.IsInteractable())
     {
         UISystemProfilerApi.AddMarker("Button.onClick", this);
         this.m_OnClick.Invoke();
     }
 }
Ejemplo n.º 11
0
 protected virtual void SendOnValueChanged()
 {
     UISystemProfilerApi.AddMarker("InputField.value", this);
     if (onValueChanged != null)
     {
         onValueChanged.Invoke(text);
     }
 }
Ejemplo n.º 12
0
 private void Press()
 {
     if (!IsActive() || !IsInteractable())
     {
         return;
     }
     UISystemProfilerApi.AddMarker("Button.onClick", this);
     m_OnClick.Invoke();
 }
Ejemplo n.º 13
0
 private void UpdateCull(bool cull)
 {
     if (canvasRenderer.cull != cull)
     {
         canvasRenderer.cull = cull;
         UISystemProfilerApi.AddMarker("MaskableGraphic.cullingChanged", this);
         graphic.OnCullingChanged();
     }
 }
Ejemplo n.º 14
0
 private void Cancel()
 {
     if (!IsActive() || !IsInteractable())
     {
         return;
     }
     UISystemProfilerApi.AddMarker("Button.onCancel", this);
     m_OnCancel.Invoke();
 }
Ejemplo n.º 15
0
 private void ButtonExit()
 {
     if (!IsActive() || !IsInteractable())
     {
         return;
     }
     Debug.Log("exit");
     UISystemProfilerApi.AddMarker("Button.onExit", this);
     m_OnRelease.Invoke();
 }
Ejemplo n.º 16
0
    private void PointerDown()
    {
        if (!IsActive() || !IsInteractable())
        {
            return;
        }

        UISystemProfilerApi.AddMarker("Button.onPointerDown", this);
        m_OnPointerDown.Invoke();
    }
Ejemplo n.º 17
0
 private void Press()
 {
     Debug.LogFormat("Button was pressed.");
     if (!IsActive() || !IsInteractable())
     {
         return;
     }
     UISystemProfilerApi.AddMarker("TargetButton.onClick", this);
     chooseTargetEvent.Invoke();             // Attacks the target chosen by UIManager
 }
Ejemplo n.º 18
0
    private void ButtonRelease()
    {
        if (!IsActive() || !IsInteractable())
        {
            return;
        }

        UISystemProfilerApi.AddMarker("Button.onRelease", this);
        m_OnRelease.Invoke();
    }
Ejemplo n.º 19
0
 private void UpdateCull(bool cull)
 {
     if (base.canvasRenderer.cull != cull)
     {
         base.canvasRenderer.cull = cull;
         UISystemProfilerApi.AddMarker("MaskableGraphic.cullingChanged", this);
         this.m_OnCullStateChanged.Invoke(cull);
         this.OnCullingChanged();
     }
 }
Ejemplo n.º 20
0
        public override void OnPointerExit(PointerEventData eventData)
        {
            base.OnPointerExit(eventData);
            MouseLeaveEventHandler mouseLeave = MouseLeaveEvent;

            if (mouseLeave != null)
            {
                UISystemProfilerApi.AddMarker("UIElement.onMouseLeave", this);
                mouseLeave();
            }
        }
Ejemplo n.º 21
0
        public override void OnPointerEnter(PointerEventData eventData)
        {
            base.OnPointerEnter(eventData);
            MouseEnterEventHandler mouseEnter = MouseEnterEvent;

            if (mouseEnter != null)
            {
                UISystemProfilerApi.AddMarker("UIElement.onMouseEnter", this);
                mouseEnter();
            }
        }
Ejemplo n.º 22
0
        public override void OnDeselect(BaseEventData eventData)
        {
            base.OnDeselect(eventData);
            DeselectEventHandler deselect = DeselectEvent;

            if (deselect != null)
            {
                UISystemProfilerApi.AddMarker("UIElement.onDeselect", this);
                deselect();
            }
        }
Ejemplo n.º 23
0
        protected override void OnEnable()
        {
            base.OnEnable();
            EnableEventHandler enable = EnableEvent;

            if (enable != null)
            {
                UISystemProfilerApi.AddMarker("UIElement.onEnable", this);
                enable();
            }
        }
Ejemplo n.º 24
0
 private void UpdateCull(bool cull)
 {
     if (canvasRenderer.cull != cull)
     {
         canvasRenderer.cull = cull;
         // TODO ²»¶®
         UISystemProfilerApi.AddMarker("MaskableGraphic.cullingChanged", this);
         m_OnCullStateChanged.Invoke(cull);
         OnCullingChanged();
     }
 }
 private void Set(bool value, bool sendCallback = true)
 {
     isExpanded = value;
     PlayEffect(fadeTime <= 0);
     if (sendCallback)
     {
         UISystemProfilerApi.AddMarker("TreeItemExpander.value", this);
         onValueChanged?.Invoke(isExpanded);
     }
     UpdateState();
 }
        private void Press()
        {
            if (!IsActive() || !IsInteractable())
            {
                return;
            }

            Debug.LogError("custom presss Runtime");

            UISystemProfilerApi.AddMarker("Button.onClick", this);
            m_OnClick.Invoke();
        }
Ejemplo n.º 27
0
        private void Up()
        {
            if (!IsActive() || !IsInteractable())
            {
                return;
            }

            _down = false;

            UISystemProfilerApi.AddMarker("Button.onUp", this);
            m_OnUp.Invoke();
        }
Ejemplo n.º 28
0
        private void UpdateCull(bool cull)
        {
            bool flag = base.canvasRenderer.cull != cull;

            base.canvasRenderer.cull = cull;
            if (flag)
            {
                UISystemProfilerApi.AddMarker("MaskableGraphic.cullingChanged", this);
                this.m_OnCullStateChanged.Invoke(cull);
                this.SetVerticesDirty();
            }
        }
        private void UpdateCull(bool cull)
        {
            var cullingChanged = canvasRenderer.cull != cull;

            canvasRenderer.cull = cull;

            if (cullingChanged)
            {
                UISystemProfilerApi.AddMarker("MaskableGraphic.cullingChanged", this);
                m_OnCullStateChanged.Invoke(cull);
                SetVerticesDirty();
            }
        }
Ejemplo n.º 30
0
        protected override void OnDisable()
        {
            base.OnDisable();
#if UNITY_EDITOR
            Subscribe(false);
#endif
            DisableEventHandler disable = DisableEvent;
            if (disable != null)
            {
                UISystemProfilerApi.AddMarker("UIElement.onDisable", this);
                disable();
            }
        }