com.xmobitea.changx.observertype
v1.5.2
Published
XmobiTea Unity Toolkit packages
Downloads
352
Readme
XmobiTea ObserverType
Serializable value wrappers with UnityEvent<T> change hooks for Unity projects.
Read By Task
| Task | Open |
| --- | --- |
| Quick package summary and routing | AI_USAGE.md |
| Generate normal runtime code with observers | AI_USE_OBSERVERS.md |
| Check exact APIs, type matrix, casts | AI_API_REFERENCE.md |
| Check notification, null, editor behavior | AI_BEHAVIOR.md |
| Install/setup package or asmdef references | AI_SETUP.md |
| Maintain or modify this package | AGENTS.md |
Fast Contract
- Namespace:
XmobiTea.ObserverType - Write with notification:
SetValue(value) - Silent write:
SetValueWithoutNotify(value) - Read:
GetValue()or implicit cast - Event:
onValueChanged SetValue(...)always invokes listeners, even for unchanged values.- Inspector edits are silent.
++and--are silent where those operators exist. ObserverCustom<T>has no dedicated custom property drawer.
Types
ObserverBoolObserverByteObserverSByteObserverShortObserverUShortObserverIntObserverUIntObserverLongObserverULongObserverFloatObserverDoubleObserverCharObserverStringObserverCustom<T>
Minimal Example
using UnityEngine;
using XmobiTea.ObserverType;
public sealed class ScoreView : MonoBehaviour
{
[SerializeField] private ObserverInt score = new ObserverInt();
private void Awake()
{
score ??= new ObserverInt();
score.onValueChanged.AddListener(OnScoreChanged);
}
private void OnDestroy()
{
if (score != null)
score.onValueChanged.RemoveListener(OnScoreChanged);
}
public void AddScore(int amount)
{
score.SetValue(score.GetValue() + amount);
}
private void OnScoreChanged(int value)
{
Debug.Log(value);
}
}Package Metadata
- Package:
com.xmobitea.changx.observertype - Version:
1.5.2 - Unity:
2022.3+ - Package dependency:
com.xmobitea.changx.app1.5.2 - Runtime asmdef:
com.xmobitea.changx.observer-type.runtime - Editor asmdef:
com.xmobitea.changx.observer-type.editor
