Skip to content

Commit

Permalink
Add a method to force refresh interactivity
Browse files Browse the repository at this point in the history
  • Loading branch information
BadMagic100 committed Nov 20, 2022
1 parent a8d43f1 commit 6364275
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions MagicUI/Behaviours/InteractivityController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ internal class InteractivityController : MonoBehaviour
private bool hasCachedAlpha = false;
private float cachedAlpha;

internal void ForceUpdate()
{
Update();
}

private void Update()
{
CanvasGroup grp = GetComponent<CanvasGroup>();
Expand Down
8 changes: 8 additions & 0 deletions MagicUI/Core/LayoutRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,14 @@ public IEnumerable<T> GetElements<T>(string name) where T : ArrangableElement
return layoutOrchestrator.Find<T>(name);
}

/// <summary>
/// Forces the interactivity controller to immediately re-evaluate interactivity conditions without needing to wait a frame
/// </summary>
public void ForceInteractivityRefresh()
{
interactivityController.ForceUpdate();
}

/// <summary>
/// Destroys the layout root and all of its child elements
/// </summary>
Expand Down

0 comments on commit 6364275

Please sign in to comment.