ScriptableData/Runtime/ScriptableData.cs

255 lines
4.1 KiB
C#
Raw Normal View History

2021-12-22 12:53:49 +01:00
using System;
using UnityEngine;
namespace ScriptableData
{
public class ScriptableData<T0> : ScriptableObject
{
public event Action<T0> OnValueChangedEvent;
[NonSerialized] private T0 _value;
2021-12-22 12:53:49 +01:00
public T0 Value
{
get
{
return _value;
}
set
{
_value = value;
OnValueChangedEvent?.Invoke(_value);
}
}
public void SetWithoutNotify(T0 value)
{
_value = value;
}
public void Invoke(T0 value)
{
_value = value;
OnValueChangedEvent?.Invoke(value);
}
}
public class ScriptableData<T0, T1> : ScriptableObject
{
public event Action<T0, T1> OnValueChangedEvent;
[NonSerialized] private T0 _value;
2021-12-22 12:53:49 +01:00
public T0 Value
{
get
{
return _value;
}
set
{
_value = value;
OnValueChangedEvent?.Invoke(_value, _value1);
}
}
[NonSerialized] private T1 _value1;
2021-12-22 12:53:49 +01:00
public T1 Value1
{
get
{
return _value1;
}
set
{
_value1 = value;
OnValueChangedEvent?.Invoke(_value, _value1);
}
}
public void SetWithoutNotify(T0 value)
{
_value = value;
}
public void SetWithoutNotify(T0 value, T1 value1)
{
_value = value;
_value1 = value1;
}
public void Invoke(T0 value, T1 value1)
{
Value = value;
Value1 = value1;
OnValueChangedEvent?.Invoke(value, value1);
}
}
public class ScriptableData<T0, T1, T2> : ScriptableObject
{
public event Action<T0, T1, T2> OnValueChangedEvent;
[NonSerialized] private T0 _value;
2021-12-22 12:53:49 +01:00
public T0 Value
{
get
{
return _value;
}
set
{
_value = value;
OnValueChangedEvent?.Invoke(_value, _value1, _value2);
}
}
[NonSerialized] private T1 _value1;
2021-12-22 12:53:49 +01:00
public T1 Value1
{
get
{
return _value1;
}
set
{
_value1 = value;
OnValueChangedEvent?.Invoke(_value, _value1, _value2);
}
}
[NonSerialized] private T2 _value2;
2021-12-22 12:53:49 +01:00
public T2 Value2
{
get
{
return _value2;
}
set
{
_value2 = value;
OnValueChangedEvent?.Invoke(_value, _value1, _value2);
}
}
public void SetWithoutNotify(T0 value)
{
_value = value;
}
public void SetWithoutNotify(T0 value, T1 value1)
{
_value = value;
_value1 = value1;
}
public void SetWithoutNotify(T0 value, T1 value1, T2 value2)
{
_value = value;
_value1 = value1;
_value2 = value2;
}
public void Invoke(T0 value, T1 value1, T2 value2)
{
Value = value;
Value1 = value1;
Value2 = value2;
OnValueChangedEvent?.Invoke(value, value1, value2);
}
}
public class ScriptableData<T0, T1, T2, T3> : ScriptableObject
{
public event Action<T0, T1, T2, T3> OnValueChangedEvent;
[NonSerialized] private T0 _value;
2021-12-22 12:53:49 +01:00
public T0 Value
{
get
{
return _value;
}
set
{
_value = value;
OnValueChangedEvent?.Invoke(_value, _value1, _value2, _value3);
}
}
[NonSerialized] private T1 _value1;
2021-12-22 12:53:49 +01:00
public T1 Value1
{
get
{
return _value1;
}
set
{
_value1 = value;
OnValueChangedEvent?.Invoke(_value, _value1, _value2, _value3);
}
}
[NonSerialized] private T2 _value2;
2021-12-22 12:53:49 +01:00
public T2 Value2
{
get
{
return _value2;
}
set
{
_value2 = value;
OnValueChangedEvent?.Invoke(_value, _value1, _value2, _value3);
}
}
[NonSerialized] private T3 _value3;
2021-12-22 12:53:49 +01:00
public T3 Value3
{
get
{
return _value3;
}
set
{
_value3 = value;
OnValueChangedEvent?.Invoke(_value, _value1, _value2, _value3);
}
}
public void SetWithoutNotify(T0 value)
{
_value = value;
}
public void SetWithoutNotify(T0 value, T1 value1)
{
_value = value;
_value1 = value1;
}
public void SetWithoutNotify(T0 value, T1 value1, T2 value2)
{
_value = value;
_value1 = value1;
_value2 = value2;
}
public void SetWithoutNotify(T0 value, T1 value1, T2 value2, T3 value3)
{
_value = value;
_value1 = value1;
_value2 = value2;
_value3 = value3;
}
public void Invoke(T0 value, T1 value1, T2 value2, T3 value3)
{
Value = value;
Value1 = value1;
Value2 = value2;
Value3 = value3;
OnValueChangedEvent?.Invoke(value, value1, value2, value3);
}
}
}