diff options
| author | chai <215380520@qq.com> | 2024-05-19 16:05:01 +0800 |
|---|---|---|
| committer | chai <215380520@qq.com> | 2024-05-19 16:05:01 +0800 |
| commit | c5f145786f4c6d2fe4bea831dfc16e52228920a5 (patch) | |
| tree | a6ead7ea8266c767d58ed0f816dcd7a1dd75bd65 /Rewired/Rewired.Demos.GamepadTemplateUI/ControllerUIEffect.cs | |
| parent | 48b64e573a1709dc923cb9162b55be0246b3ff63 (diff) | |
* move
Diffstat (limited to 'Rewired/Rewired.Demos.GamepadTemplateUI/ControllerUIEffect.cs')
| -rw-r--r-- | Rewired/Rewired.Demos.GamepadTemplateUI/ControllerUIEffect.cs | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/Rewired/Rewired.Demos.GamepadTemplateUI/ControllerUIEffect.cs b/Rewired/Rewired.Demos.GamepadTemplateUI/ControllerUIEffect.cs deleted file mode 100644 index 695aa76..0000000 --- a/Rewired/Rewired.Demos.GamepadTemplateUI/ControllerUIEffect.cs +++ /dev/null @@ -1,57 +0,0 @@ -using UnityEngine; -using UnityEngine.UI; - -namespace Rewired.Demos.GamepadTemplateUI; - -[RequireComponent(typeof(Image))] -public class ControllerUIEffect : MonoBehaviour -{ - [SerializeField] - private Color _highlightColor = Color.white; - - private Image _image; - - private Color _color; - - private Color _origColor; - - private bool _isActive; - - private float _highlightAmount; - - private void Awake() - { - _image = GetComponent<Image>(); - _origColor = _image.color; - _color = _origColor; - } - - public void Activate(float amount) - { - amount = Mathf.Clamp01(amount); - if (!_isActive || amount != _highlightAmount) - { - _highlightAmount = amount; - _color = Color.Lerp(_origColor, _highlightColor, _highlightAmount); - _isActive = true; - RedrawImage(); - } - } - - public void Deactivate() - { - if (_isActive) - { - _color = _origColor; - _highlightAmount = 0f; - _isActive = false; - RedrawImage(); - } - } - - private void RedrawImage() - { - _image.color = _color; - _image.enabled = _isActive; - } -} |
