| | | 1 | | using UnityEngine; |
| | | 2 | | #if SCRIPTABLE_VALUES_PROPERTIES |
| | | 3 | | using Unity.Properties; |
| | | 4 | | #endif |
| | | 5 | | |
| | | 6 | | namespace Hertzole.ScriptableValues |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Base class for all <see cref="ScriptableValue{TValue}" />. |
| | | 10 | | /// </summary> |
| | | 11 | | /// <remarks>You should probably inherit from <see cref="ScriptableList{T}" /> instead.</remarks> |
| | | 12 | | #if UNITY_EDITOR |
| | | 13 | | [HelpURL(Documentation.SCRIPTABLE_VALUE_URL)] |
| | | 14 | | #endif |
| | | 15 | | public abstract partial class ScriptableValue : RuntimeScriptableObject, ICanBeReadOnly |
| | | 16 | | { |
| | | 17 | | [SerializeField] |
| | | 18 | | [EditorTooltip("If read only, the value cannot be changed at runtime.")] |
| | | 19 | | #if SCRIPTABLE_VALUES_PROPERTIES |
| | | 20 | | [DontCreateProperty] |
| | | 21 | | #endif |
| | 15123 | 22 | | internal bool isReadOnly = false; |
| | | 23 | | [SerializeField] |
| | | 24 | | [EditorTooltip("If true, the value will be reset to the default value on play mode start/game boot.")] |
| | | 25 | | #if SCRIPTABLE_VALUES_PROPERTIES |
| | | 26 | | [DontCreateProperty] |
| | | 27 | | #endif |
| | 15123 | 28 | | internal bool resetValueOnStart = true; |
| | | 29 | | [SerializeField] |
| | | 30 | | [EditorTooltip("If true, an equality check will be run before setting the value to make sure the new value is no |
| | | 31 | | #if SCRIPTABLE_VALUES_PROPERTIES |
| | | 32 | | [DontCreateProperty] |
| | | 33 | | #endif |
| | 15123 | 34 | | internal bool setEqualityCheck = true; |
| | | 35 | | |
| | | 36 | | /// <summary> |
| | | 37 | | /// If read only, the value cannot be changed at runtime. |
| | | 38 | | /// </summary> |
| | | 39 | | #if SCRIPTABLE_VALUES_PROPERTIES |
| | | 40 | | [CreateProperty] |
| | | 41 | | #endif |
| | | 42 | | public bool IsReadOnly |
| | | 43 | | { |
| | 115281 | 44 | | get { return isReadOnly; } |
| | 8343 | 45 | | set { SetField(ref isReadOnly, value, isReadOnlyChangingArgs, isReadOnlyChangedArgs); } |
| | | 46 | | } |
| | | 47 | | /// <summary> |
| | | 48 | | /// If <c>true</c>, the value will be reset to the default value on play mode start/game boot. |
| | | 49 | | /// </summary> |
| | | 50 | | #if SCRIPTABLE_VALUES_PROPERTIES |
| | | 51 | | [CreateProperty] |
| | | 52 | | #endif |
| | | 53 | | public bool ResetValueOnStart |
| | | 54 | | { |
| | 51264 | 55 | | get { return resetValueOnStart; } |
| | 15129 | 56 | | set { SetField(ref resetValueOnStart, value, resetValueOnStartChangingArgs, resetValueOnStartChangedArgs); } |
| | | 57 | | } |
| | | 58 | | /// <summary> |
| | | 59 | | /// If <c>true</c>, an equality check will be run before setting the value to make sure the new value is not |
| | | 60 | | /// as the |
| | | 61 | | /// old one. |
| | | 62 | | /// </summary> |
| | | 63 | | #if SCRIPTABLE_VALUES_PROPERTIES |
| | | 64 | | [CreateProperty] |
| | | 65 | | #endif |
| | | 66 | | public bool SetEqualityCheck |
| | | 67 | | { |
| | 77130 | 68 | | get { return setEqualityCheck; } |
| | 17235 | 69 | | set { SetField(ref setEqualityCheck, value, setEqualityCheckChangingArgs, setEqualityCheckChangedArgs); } |
| | | 70 | | } |
| | | 71 | | |
| | | 72 | | #if UNITY_EDITOR |
| | | 73 | | // Used for the CreateAssetMenu attribute order. |
| | | 74 | | internal const int ORDER = -1000; |
| | | 75 | | #endif |
| | | 76 | | } |
| | | 77 | | } |