refactor
This commit is contained in:
37
Runtime/Engine/Code/Foundation/ConstsProperty.cs
Normal file
37
Runtime/Engine/Code/Foundation/ConstsProperty.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootKit.Engine.Foundation {
|
||||
[Serializable]
|
||||
public struct ConstsProperty<T> {
|
||||
[SerializeField] T m_InlineValue;
|
||||
[SerializeField] ConstantsAsset<T> m_Asset;
|
||||
[SerializeField] bool m_UseInlineValue;
|
||||
|
||||
public ConstsProperty(T value) {
|
||||
m_InlineValue = value;
|
||||
m_Asset = null;
|
||||
m_UseInlineValue = true;
|
||||
}
|
||||
|
||||
public ConstsProperty(ConstantsAsset<T> asset) {
|
||||
m_InlineValue = default;
|
||||
m_Asset = asset;
|
||||
m_UseInlineValue = false;
|
||||
}
|
||||
|
||||
public T Value {
|
||||
get {
|
||||
if (m_UseInlineValue) {
|
||||
return m_InlineValue;
|
||||
}
|
||||
|
||||
if (m_Asset != null) {
|
||||
return m_Asset.Value;
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user