您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
39 行
776 B
39 行
776 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.Equals(value))
|
|
return;
|
|
m_CachedValue = value;
|
|
onChanged?.Invoke(m_CachedValue);
|
|
}
|
|
}
|
|
|
|
public void SetNoCallback(T value)
|
|
{
|
|
m_CachedValue = value;
|
|
}
|
|
|
|
T m_CachedValue = default;
|
|
}
|
|
}
|