您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
45 行
890 B
45 行
890 B
using System;
|
|
using UnityEngine;
|
|
|
|
namespace LobbyRelaySample
|
|
{
|
|
public class CallbackValue<T>
|
|
{
|
|
public Action<T> onChanged;
|
|
|
|
|
|
public CallbackValue()
|
|
{
|
|
|
|
}
|
|
public CallbackValue(T cachedValue)
|
|
{
|
|
m_CachedValue = cachedValue;
|
|
}
|
|
|
|
public T Value
|
|
{
|
|
get => m_CachedValue;
|
|
set
|
|
{
|
|
if (m_CachedValue!=null&&m_CachedValue.Equals(value))
|
|
return;
|
|
m_CachedValue = value;
|
|
onChanged?.Invoke(m_CachedValue);
|
|
}
|
|
}
|
|
|
|
public void ForceSet(T value)
|
|
{
|
|
m_CachedValue = value;
|
|
onChanged?.Invoke(m_CachedValue);
|
|
}
|
|
|
|
public void SetNoCallback(T value)
|
|
{
|
|
m_CachedValue = value;
|
|
}
|
|
|
|
T m_CachedValue = default;
|
|
}
|
|
}
|