diff --git a/CHANGELOG.md b/CHANGELOG.md index 336f713f405589a27e3bfc657ad051d838e43e05..f461aa09843b5a5f047669b6f3f4ac06f0393e35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## 1.0.4 - 2025-07-03 + +### Changed + +- Update how prefabs handle coroutine. +- Update URP material version. + ## 1.0.3 - 2025-07-02 ### Fixed diff --git a/Runtime/Art/Materials/CircularButton/ButtonBorder.mat b/Runtime/Art/Materials/CircularButton/ButtonBorder.mat index 4bf53748e17b8b33e4266c8f4c9f57ff9a991a23..399ec9984d9abab782ec480308254630d0c4f58b 100644 --- a/Runtime/Art/Materials/CircularButton/ButtonBorder.mat +++ b/Runtime/Art/Materials/CircularButton/ButtonBorder.mat @@ -140,4 +140,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} m_Name: m_EditorClassIdentifier: - version: 9 + version: 10 diff --git a/Runtime/Art/Materials/CircularButton/CircularButtonIcon.mat b/Runtime/Art/Materials/CircularButton/CircularButtonIcon.mat index eb3cb15be90c85b0271dd927fe3d8b217534eedf..8b2ea27d0f81559869f28eff99b0afbb363025da 100644 --- a/Runtime/Art/Materials/CircularButton/CircularButtonIcon.mat +++ b/Runtime/Art/Materials/CircularButton/CircularButtonIcon.mat @@ -137,4 +137,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} m_Name: m_EditorClassIdentifier: - version: 9 + version: 10 diff --git a/Runtime/Art/Materials/Controller/DiConCircle.mat b/Runtime/Art/Materials/Controller/DiConCircle.mat index 978ac4f031af60fe9fe35f8187f3bdeea1cd92af..210e459ac9186b5cd50d9bd86b3673eaa12022db 100644 --- a/Runtime/Art/Materials/Controller/DiConCircle.mat +++ b/Runtime/Art/Materials/Controller/DiConCircle.mat @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} m_Name: m_EditorClassIdentifier: - version: 9 + version: 10 --- !u!21 &2100000 Material: serializedVersion: 8 diff --git a/Runtime/Art/Materials/Controller/DiConCore.mat b/Runtime/Art/Materials/Controller/DiConCore.mat index 308f91324ab4afe8baaa32ecf060635fdfb0077d..926ad923f8ba3cc8258228b300cdfea38f1801cd 100644 --- a/Runtime/Art/Materials/Controller/DiConCore.mat +++ b/Runtime/Art/Materials/Controller/DiConCore.mat @@ -121,6 +121,7 @@ Material: - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - _Position: {r: 0, g: 0, b: 0, a: 0} m_BuildTextureStacks: [] + m_AllowLocking: 1 --- !u!114 &6463663647676341978 MonoBehaviour: m_ObjectHideFlags: 11 @@ -133,4 +134,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} m_Name: m_EditorClassIdentifier: - version: 9 + version: 10 diff --git a/Runtime/Art/Materials/Controller/TriConBound.mat b/Runtime/Art/Materials/Controller/TriConBound.mat index 8cde9b961b04ec497cd115d5cb3c8849fe2debbf..54fc5be4b50ad69a036ed3ee88759796540a3489 100644 --- a/Runtime/Art/Materials/Controller/TriConBound.mat +++ b/Runtime/Art/Materials/Controller/TriConBound.mat @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} m_Name: m_EditorClassIdentifier: - version: 9 + version: 10 --- !u!21 &2100000 Material: serializedVersion: 8 @@ -144,3 +144,4 @@ Material: - _FrontColor: {r: 5.5908804, g: 0, b: 3.9941745, a: 0.31764707} - _VertexAmount: {r: 0.02, g: 0.02, b: 0.02, a: 0} m_BuildTextureStacks: [] + m_AllowLocking: 1 diff --git a/Runtime/Art/Materials/Controller/TriConCircleA.mat b/Runtime/Art/Materials/Controller/TriConCircleA.mat index 0b3a690780651a1fdcadc21e0e2de449ea46a77f..0ee47a7130f4d956c8d7b4870b47c24694533991 100644 --- a/Runtime/Art/Materials/Controller/TriConCircleA.mat +++ b/Runtime/Art/Materials/Controller/TriConCircleA.mat @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} m_Name: m_EditorClassIdentifier: - version: 9 + version: 10 --- !u!21 &2100000 Material: serializedVersion: 8 diff --git a/Runtime/Art/Materials/Controller/TriConCircleB.mat b/Runtime/Art/Materials/Controller/TriConCircleB.mat index 4a2b86ee6e92641aacb17c28bb57c08bbdbe3ee7..7f31b3470a601974ed5f23ea734b57cd4a6faea2 100644 --- a/Runtime/Art/Materials/Controller/TriConCircleB.mat +++ b/Runtime/Art/Materials/Controller/TriConCircleB.mat @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} m_Name: m_EditorClassIdentifier: - version: 9 + version: 10 --- !u!21 &2100000 Material: serializedVersion: 8 diff --git a/Runtime/Art/Materials/Controller/TriConCore.mat b/Runtime/Art/Materials/Controller/TriConCore.mat index 9367b4e32400e85820a7eb6d615cb7566afd87e8..5624001faae79b6c6229b8d5f80b998cf5497ce0 100644 --- a/Runtime/Art/Materials/Controller/TriConCore.mat +++ b/Runtime/Art/Materials/Controller/TriConCore.mat @@ -121,6 +121,7 @@ Material: - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - _Position: {r: -2.1472923e-10, g: 0.00000074505806, b: 0.00000074505806, a: 0} m_BuildTextureStacks: [] + m_AllowLocking: 1 --- !u!114 &6463663647676341978 MonoBehaviour: m_ObjectHideFlags: 11 @@ -133,4 +134,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} m_Name: m_EditorClassIdentifier: - version: 9 + version: 10 diff --git a/Runtime/Scripts/CircularButton/CircularButton.cs b/Runtime/Scripts/CircularButton/CircularButton.cs index 77b67c391433053ea11e3bed4c60498fefa3fc98..497d985684d26c62d39d105dac05fb9d4704b738 100644 --- a/Runtime/Scripts/CircularButton/CircularButton.cs +++ b/Runtime/Scripts/CircularButton/CircularButton.cs @@ -18,19 +18,21 @@ namespace Hyper.Interaction [SerializeField] protected Transform buttonVisualTransform; [SerializeField] protected PokeInteractable pokeInteractable; - protected bool IsHovered; - protected float StartingButtonVisualZPosition; + protected bool _isHovered; + protected float _startingButtonVisualZPosition; + protected Coroutine _animateActiveStateCoroutine; + private Coroutine _activateAfterDelayCoroutine; private void Awake() { - StartingButtonVisualZPosition = buttonVisualTransform.localPosition.z; + _startingButtonVisualZPosition = buttonVisualTransform.localPosition.z; } private void Update() { - if (!IsHovered) return; + if (!_isHovered) return; - var normalizedValue = Mathf.InverseLerp(0, StartingButtonVisualZPosition, buttonVisualTransform.localPosition.z); + var normalizedValue = Mathf.InverseLerp(0, _startingButtonVisualZPosition, buttonVisualTransform.localPosition.z); var newScaleValue = Mathf.Lerp(borderPressScale, borderDefaultScale, normalizedValue); borderTransform.localScale = new Vector3(newScaleValue, newScaleValue, 1f); @@ -38,46 +40,46 @@ namespace Hyper.Interaction public void OnHover() { - IsHovered = true; + _isHovered = true; } public virtual void OnUnhover() { - IsHovered = false; + _isHovered = false; borderTransform.localScale = new Vector3(borderDefaultScale, borderDefaultScale, 1f); } public virtual void OnSelect() { - StartCoroutine(AnimateBorder()); + StartCoroutine(AnimateBorderCoroutine()); } public void Activate() { - gameObject.SetActive(true); - StartCoroutine(AnimateActiveState(-180f, 0, true)); + if (_animateActiveStateCoroutine != null) StopCoroutine(_animateActiveStateCoroutine); + _animateActiveStateCoroutine = StartCoroutine(AnimateActiveStateCoroutine(-180f, 0, true)); } public void Deactivate() { - if (gameObject.activeSelf) - StartCoroutine(AnimateActiveState(0, 180f, false)); + if (_animateActiveStateCoroutine != null) StopCoroutine(_animateActiveStateCoroutine); + _animateActiveStateCoroutine = StartCoroutine(AnimateActiveStateCoroutine(0, 180f, false)); } - public virtual void ActivateAfterDelay(float delay) + public void ActivateAfterDelay(float delay) { - transform.localRotation = Quaternion.Euler(-180f, 0, 0); - gameObject.SetActive(true); - StartCoroutine(ActivateAfterDelayCoroutine(delay)); + if (_activateAfterDelayCoroutine != null) StopCoroutine(_activateAfterDelayCoroutine); + _activateAfterDelayCoroutine = StartCoroutine(ActivateAfterDelayCoroutine(delay)); } - protected IEnumerator ActivateAfterDelayCoroutine(float delay) + private IEnumerator ActivateAfterDelayCoroutine(float delay) { yield return new WaitForSeconds(delay); - StartCoroutine(AnimateActiveState(-180f, 0, true)); + Activate(); + _activateAfterDelayCoroutine = null; } - protected IEnumerator AnimateBorder() + protected IEnumerator AnimateBorderCoroutine() { var elapsedTime = 0f; @@ -93,15 +95,19 @@ namespace Hyper.Interaction yield return null; } - if (IsHovered) + if (_isHovered) borderTransform.localScale = new Vector3(borderPressScale, borderPressScale, 1f); else borderTransform.localScale = new Vector3(borderDefaultScale, borderDefaultScale, 1f); } - protected virtual IEnumerator AnimateActiveState(float startXRotation, float endXRotation, bool activeState) + protected virtual IEnumerator AnimateActiveStateCoroutine(float startXRotation, float endXRotation, bool activeState) { - if (!activeState) + if (activeState) + { + pokeInteractable.gameObject.SetActive(true); + } + else { yield return new WaitForSeconds(borderAnimDuration); pokeInteractable.enabled = false; @@ -123,9 +129,15 @@ namespace Hyper.Interaction transform.localRotation = Quaternion.Euler(0, 0, 0); if (activeState) + { pokeInteractable.enabled = true; + } else - gameObject.SetActive(false); + { + pokeInteractable.gameObject.SetActive(false); + } + + _animateActiveStateCoroutine = null; } } } diff --git a/Runtime/Scripts/CircularButton/CircularHoldButton.cs b/Runtime/Scripts/CircularButton/CircularHoldButton.cs index eafaf979d27e889c94940060cd8447b547f10b7a..7a2e03591bfc9f0dfe56f4c9b3f1bc88d5ccafd8 100644 --- a/Runtime/Scripts/CircularButton/CircularHoldButton.cs +++ b/Runtime/Scripts/CircularButton/CircularHoldButton.cs @@ -23,7 +23,7 @@ namespace Hyper.Interaction private void Awake() { - StartingButtonVisualZPosition = buttonVisualTransform.localPosition.z; + _startingButtonVisualZPosition = buttonVisualTransform.localPosition.z; _greyCircleImage = greyCircleGameObject.GetComponent<Image>(); _greenCircleImage = greenCircleGameObject.GetComponent<Image>(); _greyCircleRectTransform = greyCircleGameObject.GetComponent<RectTransform>(); @@ -38,8 +38,8 @@ namespace Hyper.Interaction _isHolding = false; buttonBorderHoldGameObject.SetActive(false); borderTransform.gameObject.SetActive(true); - StartCoroutine(AnimateBorder()); - StartCoroutine(ResetButton()); + StartCoroutine(AnimateBorderCoroutine()); + StartCoroutine(ResetButtonCoroutine()); whenHoldDone?.Invoke(); } @@ -59,9 +59,9 @@ namespace Hyper.Interaction _greenCircleImage.fillAmount = 0; } - if (!IsHovered) return; + if (!_isHovered) return; - var normalizedValue = Mathf.InverseLerp(0, StartingButtonVisualZPosition, buttonVisualTransform.localPosition.z); + var normalizedValue = Mathf.InverseLerp(0, _startingButtonVisualZPosition, buttonVisualTransform.localPosition.z); var newScaleValue = Mathf.Lerp(borderPressScale, borderDefaultScale, normalizedValue); _greyCircleRectTransform.localScale = new Vector3(newScaleValue, newScaleValue, 1f); @@ -69,7 +69,7 @@ namespace Hyper.Interaction public override void OnUnhover() { - IsHovered = false; + _isHovered = false; _greyCircleRectTransform.localScale = new Vector3(borderDefaultScale, borderDefaultScale, 1f); } @@ -83,15 +83,7 @@ namespace Hyper.Interaction _isHolding = false; } - public override void ActivateAfterDelay(float delay) - { - _greyCircleImage.enabled = false; - transform.localRotation = Quaternion.Euler(-180f, 0, 0); - gameObject.SetActive(true); - StartCoroutine(ActivateAfterDelayCoroutine(delay)); - } - - private IEnumerator ResetButton() + private IEnumerator ResetButtonCoroutine() { yield return new WaitForSeconds(borderAnimDuration); @@ -102,9 +94,14 @@ namespace Hyper.Interaction _isHoldDone = false; } - protected override IEnumerator AnimateActiveState(float startXRotation, float endXRotation, bool activeState) + protected override IEnumerator AnimateActiveStateCoroutine(float startXRotation, float endXRotation, bool activeState) { - if (!activeState) + if (activeState) + { + _greyCircleImage.enabled = false; + pokeInteractable.gameObject.SetActive(true); + } + else { yield return new WaitForSeconds(borderAnimDuration); pokeInteractable.enabled = false; @@ -128,9 +125,15 @@ namespace Hyper.Interaction transform.localRotation = Quaternion.Euler(0, 0, 0); if (activeState) + { pokeInteractable.enabled = true; + } else - gameObject.SetActive(false); + { + pokeInteractable.gameObject.SetActive(false); + } + + _animateActiveStateCoroutine = null; } } } diff --git a/Runtime/Scripts/Controller/DiConCircle.cs b/Runtime/Scripts/Controller/DiConCircle.cs index 65633be06db2cdce58fff1f93141778158fe6d68..1aa145e1f44c434da1364cc10a07fea8f2bb014f 100644 --- a/Runtime/Scripts/Controller/DiConCircle.cs +++ b/Runtime/Scripts/Controller/DiConCircle.cs @@ -13,6 +13,7 @@ namespace Hyper.Interaction private Material _material; private Color _color; + private Coroutine _animateCoroutine; private void Start() { @@ -22,15 +23,17 @@ namespace Hyper.Interaction public void OnHover() { - StartCoroutine(Animate(unhoverScale, hoverScale, 0, 1f, animDuration)); + if (_animateCoroutine != null) StopCoroutine(_animateCoroutine); + _animateCoroutine = StartCoroutine(AnimateCoroutine(unhoverScale, hoverScale, 0, 1f, animDuration)); } public void OnUnhover() { - StartCoroutine(Animate(hoverScale, unhoverScale, 1f, 0, animDuration)); + if (_animateCoroutine != null) StopCoroutine(_animateCoroutine); + _animateCoroutine = StartCoroutine(AnimateCoroutine(hoverScale, unhoverScale, 1f, 0, animDuration)); } - private IEnumerator Animate( + private IEnumerator AnimateCoroutine( float startScale, float endScale, float startAlpha, float endAlpha, float duration @@ -52,6 +55,8 @@ namespace Hyper.Interaction yield return null; } transform.localScale = new Vector3(endScale, endScale, 1f); + + _animateCoroutine = null; } } } diff --git a/Runtime/Scripts/Controller/TriConCircle.cs b/Runtime/Scripts/Controller/TriConCircle.cs index f8994b8901647a8fc34eeae8237418cd10d9119f..d9f2b033fb0c7a60a6772f90d3ef51d95374b46b 100644 --- a/Runtime/Scripts/Controller/TriConCircle.cs +++ b/Runtime/Scripts/Controller/TriConCircle.cs @@ -13,6 +13,7 @@ namespace Hyper.Interaction [SerializeField] private AnimationCurve animCurve; private Material _material; + private Coroutine _animateCoroutine; private void Start() { @@ -21,15 +22,17 @@ namespace Hyper.Interaction public void OnHover() { - StartCoroutine(Animate(unhoverRotation, hoverRotation, 0, 1f, animDuration)); + if (_animateCoroutine != null) StopCoroutine(_animateCoroutine); + _animateCoroutine = StartCoroutine(AnimateCoroutine(unhoverRotation, hoverRotation, 0, 1f, animDuration)); } public void OnUnhover() { - StartCoroutine(Animate(hoverRotation, unhoverRotation, 1f, 0, animDuration)); + if (_animateCoroutine != null) StopCoroutine(_animateCoroutine); + _animateCoroutine = StartCoroutine(AnimateCoroutine(hoverRotation, unhoverRotation, 1f, 0, animDuration)); } - private IEnumerator Animate( + private IEnumerator AnimateCoroutine( Vector3 startRotation, Vector3 endRotation, float startAlpha, float endAlpha, float duration @@ -52,6 +55,8 @@ namespace Hyper.Interaction yield return null; } transform.rotation = Quaternion.Euler(endRotation); + + _animateCoroutine = null; } } } diff --git a/package.json b/package.json index 295594b587fdd2e58451da1a13a0b44db27cbc1a..74f1844e510849c50feb0c89238cf150fc24de9e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "de.tu-dresden.hyper.interaction", - "version": "1.0.3", + "version": "1.0.4", "displayName": "HYPER Interaction", "description": "This package provides ready-to-use interaction components.", "unity": "6000.0",