Last active
November 27, 2022 16:54
-
-
Save GCodergr/b7cd99444ed3d2f37d28788c39ef2067 to your computer and use it in GitHub Desktop.
UniRx SubscribeToText support for TextMeshPro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using TMPro; | |
namespace UniRx.Extensions | |
{ | |
public static class UnityUIExtensions | |
{ | |
public static IDisposable SubscribeToText(this IObservable<string> source, TextMeshProUGUI text) | |
{ | |
return source.SubscribeWithState(text, (x, t) => t.text = x); | |
} | |
public static IDisposable SubscribeToText<T>(this IObservable<T> source, TextMeshProUGUI text) | |
{ | |
return source.SubscribeWithState(text, (x, t) => t.text = x.ToString()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment