From 561d9e815cb16fab12ec75e0f483b67c4f72918c Mon Sep 17 00:00:00 2001 From: Walter Hulsebos Date: Mon, 8 Nov 2021 00:58:31 +0100 Subject: [PATCH 01/14] CHANGE: Naming Variable -> Var Changed naming convention from verbose "variable" and "variables" to "var" and "vars" --- Runtime/{Variables/FloatVariable.cs => Vars/FloatVar.cs} | 7 +++---- .../ReadonlyFloatVariable.cs => Vars/ReadonlyFloatVar.cs} | 7 +++---- .../{Variables/ReadonlyVariable.cs => Vars/ReadonlyVar.cs} | 6 +++--- Runtime/{Variables/Variable.cs => Vars/Var.cs} | 6 +++--- 4 files changed, 12 insertions(+), 14 deletions(-) rename Runtime/{Variables/FloatVariable.cs => Vars/FloatVar.cs} (65%) rename Runtime/{Variables/ReadonlyFloatVariable.cs => Vars/ReadonlyFloatVar.cs} (69%) rename Runtime/{Variables/ReadonlyVariable.cs => Vars/ReadonlyVar.cs} (67%) rename Runtime/{Variables/Variable.cs => Vars/Var.cs} (68%) diff --git a/Runtime/Variables/FloatVariable.cs b/Runtime/Vars/FloatVar.cs similarity index 65% rename from Runtime/Variables/FloatVariable.cs rename to Runtime/Vars/FloatVar.cs index 0942f74..3633ae1 100644 --- a/Runtime/Variables/FloatVariable.cs +++ b/Runtime/Vars/FloatVar.cs @@ -1,11 +1,10 @@ -using UnityEngine; - using Sirenix.OdinInspector; +using UnityEngine; -namespace N8.Utils.SOA.Variables +namespace N8.Utils.SOA.Vars { [CreateAssetMenu(fileName = "NewFloatVariable", menuName = "N8Dev/SOA/Variables/Float"), InlineEditor] - public sealed class FloatVariable : Variable + public sealed class FloatVar : Var { } diff --git a/Runtime/Variables/ReadonlyFloatVariable.cs b/Runtime/Vars/ReadonlyFloatVar.cs similarity index 69% rename from Runtime/Variables/ReadonlyFloatVariable.cs rename to Runtime/Vars/ReadonlyFloatVar.cs index 1c7d512..8aa08de 100644 --- a/Runtime/Variables/ReadonlyFloatVariable.cs +++ b/Runtime/Vars/ReadonlyFloatVar.cs @@ -1,11 +1,10 @@ -using UnityEngine; - using Sirenix.OdinInspector; +using UnityEngine; -namespace N8.Utils.SOA.Variables +namespace N8.Utils.SOA.Vars { [CreateAssetMenu(fileName = "NewFloatVariable", menuName = "N8Dev/SOA/Variables/Float"), InlineEditor] //TODO: That won't work, it uses the same menuName as the regular float. - public sealed class ReadonlyFloatVariable : ReadonlyVariable + public sealed class ReadonlyFloatVar : ReadonlyVar { } diff --git a/Runtime/Variables/ReadonlyVariable.cs b/Runtime/Vars/ReadonlyVar.cs similarity index 67% rename from Runtime/Variables/ReadonlyVariable.cs rename to Runtime/Vars/ReadonlyVar.cs index 4b8e05b..a951001 100644 --- a/Runtime/Variables/ReadonlyVariable.cs +++ b/Runtime/Vars/ReadonlyVar.cs @@ -1,9 +1,9 @@ using System; using UnityEngine; -namespace N8.Utils.SOA.Variables +namespace N8.Utils.SOA.Vars { - public abstract class ReadonlyVariable : ScriptableObject, ISerializationCallbackReceiver + public abstract class ReadonlyVar : ScriptableObject, ISerializationCallbackReceiver { [SerializeField] private T _value; @@ -14,7 +14,7 @@ public abstract class ReadonlyVariable : ScriptableObject, ISerializationCall public void OnBeforeSerialize() => Value = _value; public void OnAfterDeserialize() { } - public static implicit operator T(ReadonlyVariable input) => input.Value; + public static implicit operator T(ReadonlyVar input) => input.Value; public override string ToString() => Value.ToString(); } diff --git a/Runtime/Variables/Variable.cs b/Runtime/Vars/Var.cs similarity index 68% rename from Runtime/Variables/Variable.cs rename to Runtime/Vars/Var.cs index 92721eb..74c897f 100644 --- a/Runtime/Variables/Variable.cs +++ b/Runtime/Vars/Var.cs @@ -1,9 +1,9 @@ using System; using UnityEngine; -namespace N8.Utils.SOA.Variables +namespace N8.Utils.SOA.Vars { - public abstract class Variable : ScriptableObject, ISerializationCallbackReceiver + public abstract class Var : ScriptableObject, ISerializationCallbackReceiver { [SerializeField] private T _value; @@ -14,7 +14,7 @@ public abstract class Variable : ScriptableObject, ISerializationCallbackRece public void OnBeforeSerialize() => Value = _value; public void OnAfterDeserialize() { } - public static implicit operator T(Variable input) => input.Value; + public static implicit operator T(Var input) => input.Value; public override string ToString() => Value.ToString(); } From 345a596276e1462b29c2ed63b321f7c316e1ebdd Mon Sep 17 00:00:00 2001 From: Walter Hulsebos Date: Mon, 8 Nov 2021 01:22:05 +0100 Subject: [PATCH 02/14] NEW: class - Ref For ScriptableObject References --- Runtime/Refs/Ref.cs | 62 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Runtime/Refs/Ref.cs diff --git a/Runtime/Refs/Ref.cs b/Runtime/Refs/Ref.cs new file mode 100644 index 0000000..17f6002 --- /dev/null +++ b/Runtime/Refs/Ref.cs @@ -0,0 +1,62 @@ +using System; +using System.Runtime.CompilerServices; +using static System.Runtime.CompilerServices.MethodImplOptions; + +using UnityEngine; + +namespace N8.Utils.SOA +{ + using Vars; + + [Serializable] + public class Ref where TVar : Var + { + #region Fields & Properties + + [SerializeField] private T defaultValue; + [SerializeField] private TVar variable; + [SerializeField] private Boolean useDefault; + + public T Value + { + get => (variable == null || useDefault) ? defaultValue : variable; + set + { + if (useDefault) + { + defaultValue = value; + } + else + { + variable.Value = value; + } + } + } + + #endregion + + #region Structors + + public Ref() { } + public Ref(T value, Boolean useDefault = true) + { + this.useDefault = useDefault; + this.Value = value; + } + + public Ref(TVar variable, Boolean useDefault = false) + { + this.useDefault = useDefault; + this.variable = variable; + } + + #endregion + + #region Operators + + [MethodImpl(AggressiveInlining)] + public static implicit operator T(Ref input) => input.Value; + + #endregion + } +} From 9fdac69efcc04f1adc8db6ea2ca61477351c39c7 Mon Sep 17 00:00:00 2001 From: Walter Hulsebos Date: Mon, 8 Nov 2021 13:32:18 +0100 Subject: [PATCH 03/14] NEW: (Ref) Constructor T & TVar --- Runtime/Refs/Ref.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Runtime/Refs/Ref.cs b/Runtime/Refs/Ref.cs index 17f6002..b6d8b7e 100644 --- a/Runtime/Refs/Ref.cs +++ b/Runtime/Refs/Ref.cs @@ -38,6 +38,18 @@ public T Value #region Structors public Ref() { } + + public Ref(T value) + { + this.Value = value; + } + + public Ref(TVar variable) + { + this.variable = variable; + } + + /* public Ref(T value, Boolean useDefault = true) { this.useDefault = useDefault; From f11d049a167048d8392382e38cb39025f7221811 Mon Sep 17 00:00:00 2001 From: Walter Hulsebos Date: Mon, 8 Nov 2021 13:33:08 +0100 Subject: [PATCH 04/14] CHANGE: (Ref) Value - get/set IsUsingDefault check --- Runtime/Refs/Ref.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Runtime/Refs/Ref.cs b/Runtime/Refs/Ref.cs index b6d8b7e..b49ab74 100644 --- a/Runtime/Refs/Ref.cs +++ b/Runtime/Refs/Ref.cs @@ -17,12 +17,14 @@ public class Ref where TVar : Var [SerializeField] private TVar variable; [SerializeField] private Boolean useDefault; + private Boolean IsUsingDefault => (useDefault || (variable == null)); + public T Value { - get => (variable == null || useDefault) ? defaultValue : variable; + get => IsUsingDefault ? defaultValue : (T)variable; set { - if (useDefault) + if (IsUsingDefault) { defaultValue = value; } From 096a0550ff370a4ebd998efeb34be964cdd6a5c5 Mon Sep 17 00:00:00 2001 From: Walter Hulsebos Date: Mon, 8 Nov 2021 13:35:39 +0100 Subject: [PATCH 05/14] NEW: (Ref) Implicit Conversion from/to T & TVar --- Runtime/Refs/Ref.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Runtime/Refs/Ref.cs b/Runtime/Refs/Ref.cs index b49ab74..b5caf4e 100644 --- a/Runtime/Refs/Ref.cs +++ b/Runtime/Refs/Ref.cs @@ -63,13 +63,31 @@ public Ref(TVar variable, Boolean useDefault = false) this.useDefault = useDefault; this.variable = variable; } + */ + + #endregion + + #region Methods + + public override String ToString() => Value.ToString(); #endregion #region Operators + //TODO: Conversion Operators default check. + + [MethodImpl(AggressiveInlining)] + public static implicit operator T (Ref input) => input.Value; + + [MethodImpl(AggressiveInlining)] + public static implicit operator TVar (Ref input) => input.variable; + + [MethodImpl(AggressiveInlining)] + public static implicit operator Ref (T value) => new Ref(value); + [MethodImpl(AggressiveInlining)] - public static implicit operator T(Ref input) => input.Value; + public static implicit operator Ref (TVar variable) => new Ref(variable); #endregion } From 7d2f4316509dafa47e467acf493448c2f24450b5 Mon Sep 17 00:00:00 2001 From: Walter Hulsebos Date: Mon, 8 Nov 2021 15:57:28 +0100 Subject: [PATCH 06/14] CHANGE: (Ref) Renaming [variable, value, reference] variable -> var value -> val reference -> ref var doesn't conflict with C#'s var as I don't use it, and this naming is nice for brevity consistency but still informative enough. --- Runtime/Refs/Ref.cs | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Runtime/Refs/Ref.cs b/Runtime/Refs/Ref.cs index b5caf4e..3a745b3 100644 --- a/Runtime/Refs/Ref.cs +++ b/Runtime/Refs/Ref.cs @@ -9,19 +9,21 @@ namespace N8.Utils.SOA using Vars; [Serializable] - public class Ref where TVar : Var + public class Ref : IRef where TVar : Var { #region Fields & Properties - [SerializeField] private T defaultValue; - [SerializeField] private TVar variable; - [SerializeField] private Boolean useDefault; + [SerializeField] protected Boolean useDefault; + [SerializeField] protected T defaultValue; + + [field: SerializeField] + protected TVar Var { get; private set; } - private Boolean IsUsingDefault => (useDefault || (variable == null)); + private Boolean IsUsingDefault => (useDefault || (Var == null)); public T Value { - get => IsUsingDefault ? defaultValue : (T)variable; + get => IsUsingDefault ? defaultValue : (T)Var; set { if (IsUsingDefault) @@ -30,7 +32,7 @@ public T Value } else { - variable.Value = value; + Var.Value = value; } } } @@ -40,15 +42,15 @@ public T Value #region Structors public Ref() { } - - public Ref(T value) + + public Ref(T val) { - this.Value = value; + this.Value = val; } - public Ref(TVar variable) + public Ref(TVar var) { - this.variable = variable; + this.Var = var; } /* @@ -78,16 +80,14 @@ public Ref(TVar variable, Boolean useDefault = false) //TODO: Conversion Operators default check. [MethodImpl(AggressiveInlining)] - public static implicit operator T (Ref input) => input.Value; - + public static implicit operator T (Ref input) => input.Value; [MethodImpl(AggressiveInlining)] - public static implicit operator TVar (Ref input) => input.variable; + public static implicit operator TVar (Ref input) => input.Var; [MethodImpl(AggressiveInlining)] - public static implicit operator Ref (T value) => new Ref(value); - + public static implicit operator Ref (T val) => new Ref(val: val); [MethodImpl(AggressiveInlining)] - public static implicit operator Ref (TVar variable) => new Ref(variable); + public static implicit operator Ref (TVar var) => new Ref(var: var); #endregion } From 59af632a8ee9641bd44f53c885a466e0098d2a43 Mon Sep 17 00:00:00 2001 From: Walter Hulsebos Date: Sat, 13 Nov 2021 13:26:13 +0100 Subject: [PATCH 07/14] NEW: class - Vector3Var --- Runtime/Vars/Vector3Var.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Runtime/Vars/Vector3Var.cs diff --git a/Runtime/Vars/Vector3Var.cs b/Runtime/Vars/Vector3Var.cs new file mode 100644 index 0000000..8447ea1 --- /dev/null +++ b/Runtime/Vars/Vector3Var.cs @@ -0,0 +1,11 @@ +using Sirenix.OdinInspector; +using UnityEngine; + +namespace N8.Utils.SOA.Vars +{ + [CreateAssetMenu(fileName = "NewVector3Var", menuName = "N8Dev/SOA/Variables/Vector3"), InlineEditor] + public sealed class Vector3Var : Var + { + + } +} \ No newline at end of file From db9ae9b36981be0d7e3163389021eee375671535 Mon Sep 17 00:00:00 2001 From: Walter Hulsebos Date: Sat, 13 Nov 2021 13:26:29 +0100 Subject: [PATCH 08/14] NEW: class - Vector3Ref --- Runtime/Refs/Ref.cs | 2 ++ Runtime/Refs/Vector3Ref.cs | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 Runtime/Refs/Vector3Ref.cs diff --git a/Runtime/Refs/Ref.cs b/Runtime/Refs/Ref.cs index 3a745b3..4c5f4d8 100644 --- a/Runtime/Refs/Ref.cs +++ b/Runtime/Refs/Ref.cs @@ -8,6 +8,8 @@ namespace N8.Utils.SOA { using Vars; + public interface IRef { } //for PropertyDrawer purposes + [Serializable] public class Ref : IRef where TVar : Var { diff --git a/Runtime/Refs/Vector3Ref.cs b/Runtime/Refs/Vector3Ref.cs new file mode 100644 index 0000000..6582a29 --- /dev/null +++ b/Runtime/Refs/Vector3Ref.cs @@ -0,0 +1,30 @@ +using System; +using System.Runtime.CompilerServices; +using static System.Runtime.CompilerServices.MethodImplOptions; + +using UnityEngine; + +namespace N8.Utils.SOA.Refs +{ + using Vars; + + [Serializable] + public sealed class Vector3Ref : Ref + { + public Vector3Ref() : base() { } + public Vector3Ref(Vector3 val) : base(val: val) { } + public Vector3Ref(Vector3Var var) : base(var: var) { } + //public Vector3Ref(Vector3 value, Boolean useDefault = true) : base(value: value, useDefault: useDefault) { } + //public Vector3Ref(Vector3Var variable, Boolean useDefault = false) : base(variable: variable, useDefault: useDefault) { } + + [MethodImpl(AggressiveInlining)] + public static implicit operator Vector3 (Vector3Ref input) => input.Value; + [MethodImpl(AggressiveInlining)] + public static implicit operator Vector3Var (Vector3Ref input) => input.Var; + + [MethodImpl(AggressiveInlining)] + public static implicit operator Vector3Ref (Vector3 val) => new Vector3Ref(val: val); + [MethodImpl(AggressiveInlining)] + public static implicit operator Vector3Ref (Vector3Var var) => new Vector3Ref(var: var); + } +} \ No newline at end of file From a86ae2efc7b64bc590016340217d88af3e2f9b70 Mon Sep 17 00:00:00 2001 From: Walter Hulsebos Date: Sat, 13 Nov 2021 14:52:37 +0100 Subject: [PATCH 09/14] CHANGE: (Var) Added regions to code + Attempt at "Constructors" --- Editor/N8.Utils.SOA.Editor.asmdef | 4 ++- Editor/RefPropertyDrawer.cs | 50 +++++++++++++++++++++++++++++++ Runtime/Vars/Var.cs | 42 ++++++++++++++++++++++++-- package.json | 4 +-- 4 files changed, 94 insertions(+), 6 deletions(-) create mode 100644 Editor/RefPropertyDrawer.cs diff --git a/Editor/N8.Utils.SOA.Editor.asmdef b/Editor/N8.Utils.SOA.Editor.asmdef index ce39f94..0f022fe 100644 --- a/Editor/N8.Utils.SOA.Editor.asmdef +++ b/Editor/N8.Utils.SOA.Editor.asmdef @@ -1,7 +1,9 @@ { "name": "N8.Utils.SOA.Editor", "rootNamespace": "N8.Utils.SOA.Editor", - "references": [], + "references": [ + "N8.Utils.SOA" + ], "includePlatforms": [], "excludePlatforms": [], "allowUnsafeCode": false, diff --git a/Editor/RefPropertyDrawer.cs b/Editor/RefPropertyDrawer.cs new file mode 100644 index 0000000..9bf726e --- /dev/null +++ b/Editor/RefPropertyDrawer.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using UnityEditor; +using UnityEditor.UIElements; +using UnityEngine; +using UnityEngine.UIElements; + +namespace N8.Utils.SOA.Editor +{ + //[CustomPropertyDrawer(type: typeof(IRef), useForChildren: true)] + public sealed class RefPropertyDrawer : PropertyDrawer + { + public override VisualElement CreatePropertyGUI(SerializedProperty property) + { + VisualElement container = new VisualElement(); + + Debug.Log("Active"); + + FloatField floatField = new FloatField(label: "Fancy Label"); + + floatField.RegisterCallback>(callback: evt => + { + Debug.Log(evt.newValue); + }); + + //PropertyField useDefault = new PropertyField(property.FindPropertyRelative(_USE_DEFAULT)); + //PropertyField defaultValue = new PropertyField(property.FindPropertyRelative(_DEFAULT_VALUE)); + //PropertyField variable = new PropertyField(property.FindPropertyRelative(_VAR)); + + //SerializedProperty useDefault = property.FindPropertyRelative(_USE_DEFAULT); + //SerializedProperty defaultValue = property.FindPropertyRelative(_DEFAULT_VALUE); + //SerializedProperty variable = property.FindPropertyRelative(_VAR); + + //var t = new PopupField(label: "Test", choices: new List {1f, 2f, 3f}, defaultValue: 1f); + //container.Add(t); + + //container.Add(useDefault); + //container.Add(defaultValue); + //container.Add(variable); + + return container; + } + + /* + private const String _USE_DEFAULT = "useDefault"; + private const String _DEFAULT_VALUE = "defaultValue"; + private const String _VAR = "Var"; + */ + } +} diff --git a/Runtime/Vars/Var.cs b/Runtime/Vars/Var.cs index 74c897f..71fa1fa 100644 --- a/Runtime/Vars/Var.cs +++ b/Runtime/Vars/Var.cs @@ -5,17 +5,53 @@ namespace N8.Utils.SOA.Vars { public abstract class Var : ScriptableObject, ISerializationCallbackReceiver { + #region Fields & Properties + [SerializeField] private T _value; - [field: NonSerialized] //Shouldn't be serialized anyhow, even with Odin installed, right? public T Value { get; set; } + #endregion + + /* + //TODO: Figure these out. + #region "Structors" + + public static Var New() + { + Var newVar = CreateInstance>(); + + return newVar; + } + + public static Var New(T val) + { + Var newVar = CreateInstance>(); + + newVar.Value = val; + + return newVar; + } + + #endregion + */ + + #region Methods + public void OnBeforeSerialize() => Value = _value; public void OnAfterDeserialize() { } - public static implicit operator T(Var input) => input.Value; - public override string ToString() => Value.ToString(); + public override String ToString() => Value.ToString(); + + #endregion + + #region Operators + + //Can't work in reverse because ScriptableObjects can't be created via constructor. + public static implicit operator T(Var input) => input.Value; + + #endregion } } \ No newline at end of file diff --git a/package.json b/package.json index 1c5f138..849b3d9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "com.n8dev.utils.soa", - "displayName": "N8Dev.Utils.SOA", + "name": "com.n8.utils.soa", + "displayName": "N8.Utils.SOA", "version": "0.1.0", "description": "Delivers flexible decoupling via ScriptableObject editor references inside Unity.", "keywords": [ From c03f13b4802385099e9d0778f7f3f696a2abfdde Mon Sep 17 00:00:00 2001 From: Walter Hulsebos Date: Sat, 13 Nov 2021 14:54:45 +0100 Subject: [PATCH 10/14] NEW: (Vector3Var) Methods New & New(val) as faux constructors. --- Runtime/Vars/Vector3Var.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Runtime/Vars/Vector3Var.cs b/Runtime/Vars/Vector3Var.cs index 8447ea1..78f8961 100644 --- a/Runtime/Vars/Vector3Var.cs +++ b/Runtime/Vars/Vector3Var.cs @@ -6,6 +6,24 @@ namespace N8.Utils.SOA.Vars [CreateAssetMenu(fileName = "NewVector3Var", menuName = "N8Dev/SOA/Variables/Vector3"), InlineEditor] public sealed class Vector3Var : Var { + #region "Structors" + public new static Vector3Var New() + { + Vector3Var newVar = CreateInstance(); + + return newVar; + } + + public new static Vector3Var New(Vector3 val) + { + Vector3Var newVar = CreateInstance(); + + newVar.Value = val; + + return newVar; + } + + #endregion } } \ No newline at end of file From 059c535001c7e2c0b7023333d0d2f5e441a81270 Mon Sep 17 00:00:00 2001 From: Walter Hulsebos Date: Sat, 13 Nov 2021 14:56:08 +0100 Subject: [PATCH 11/14] NEW: tests - RefTests --- Tests/Editor/N8.Utils.SOA.Tests.Editor.asmdef | 24 +++++++++++++++++++ Tests/Editor/RefTests.cs | 12 ++++++++++ .../Runtime/N8.Utils.SOA.Tests.Runtime.asmdef | 22 +++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 Tests/Editor/N8.Utils.SOA.Tests.Editor.asmdef create mode 100644 Tests/Editor/RefTests.cs create mode 100644 Tests/Runtime/N8.Utils.SOA.Tests.Runtime.asmdef diff --git a/Tests/Editor/N8.Utils.SOA.Tests.Editor.asmdef b/Tests/Editor/N8.Utils.SOA.Tests.Editor.asmdef new file mode 100644 index 0000000..ce4a3c0 --- /dev/null +++ b/Tests/Editor/N8.Utils.SOA.Tests.Editor.asmdef @@ -0,0 +1,24 @@ +{ + "name": "N8.Utils.SOA.Tests.Editor", + "rootNamespace": "N8.Utils.SOA.Tests.Editor", + "references": [ + "UnityEngine.TestRunner", + "UnityEditor.TestRunner", + "N8.Utils.SOA" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [ + "nunit.framework.dll" + ], + "autoReferenced": false, + "defineConstraints": [ + "UNITY_INCLUDE_TESTS" + ], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Tests/Editor/RefTests.cs b/Tests/Editor/RefTests.cs new file mode 100644 index 0000000..1dd91ae --- /dev/null +++ b/Tests/Editor/RefTests.cs @@ -0,0 +1,12 @@ +using NUnit.Framework; +using UnityEngine; + +namespace N8.Utils.SOA.Tests.Editor +{ + using Refs; + + public class RefTests + { + + } +} diff --git a/Tests/Runtime/N8.Utils.SOA.Tests.Runtime.asmdef b/Tests/Runtime/N8.Utils.SOA.Tests.Runtime.asmdef new file mode 100644 index 0000000..0a161fc --- /dev/null +++ b/Tests/Runtime/N8.Utils.SOA.Tests.Runtime.asmdef @@ -0,0 +1,22 @@ +{ + "name": "N8.Utils.SOA.Tests.Runtime", + "rootNamespace": "N8.Utils.SOA.Tests.Runtime", + "references": [ + "UnityEngine.TestRunner", + "UnityEditor.TestRunner", + "N8.Utils.SOA" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [ + "nunit.framework.dll" + ], + "autoReferenced": false, + "defineConstraints": [ + "UNITY_INCLUDE_TESTS" + ], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file From 70b87be9fe1820eb9f3aaf4e340bbc1e13e243c8 Mon Sep 17 00:00:00 2001 From: Walter Hulsebos Date: Sat, 13 Nov 2021 14:57:27 +0100 Subject: [PATCH 12/14] NEW: (RefTests) Constructor_Empty & Constructor_T --- Tests/Editor/RefTests.cs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Tests/Editor/RefTests.cs b/Tests/Editor/RefTests.cs index 1dd91ae..a3008ba 100644 --- a/Tests/Editor/RefTests.cs +++ b/Tests/Editor/RefTests.cs @@ -7,6 +7,38 @@ namespace N8.Utils.SOA.Tests.Editor public class RefTests { + [Test] + public void Constructor_Empty() + { + Vector3Ref __vector3Ref = new Vector3Ref(); + + Assert.AreEqual( + expected: Vector3.zero, + actual: __vector3Ref.Value); + + Assert.AreNotEqual( + expected: Vector3.one, + actual: __vector3Ref.Value); + } + [Test] + public void Constructor_T() + { + Vector3Ref __vector3Ref = new Vector3Ref(val: Vector3.one); + + Assert.AreEqual( + expected: Vector3.one, + actual: __vector3Ref.Value); + + Assert.AreNotEqual( + expected: Vector3.zero, + actual: __vector3Ref.Value); + } + + [Test] + public void Constructor_TVal() + { + // Use the Assert class to test conditions + } } } From e45f759e05f702fb6e5dd0506d47a2366c04aa00 Mon Sep 17 00:00:00 2001 From: Walter Hulsebos Date: Sat, 13 Nov 2021 14:57:59 +0100 Subject: [PATCH 13/14] NEW: tests - VarTests --- Tests/Editor/VarTests.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Tests/Editor/VarTests.cs diff --git a/Tests/Editor/VarTests.cs b/Tests/Editor/VarTests.cs new file mode 100644 index 0000000..cb4b727 --- /dev/null +++ b/Tests/Editor/VarTests.cs @@ -0,0 +1,12 @@ +using NUnit.Framework; +using UnityEngine; + +namespace N8.Utils.SOA.Tests.Editor +{ + using Vars; + + public class VarTests + { + + } +} \ No newline at end of file From 049fe5fef2995caafabb682ae64e2beeaa2bf553 Mon Sep 17 00:00:00 2001 From: Walter Hulsebos Date: Sat, 13 Nov 2021 14:58:56 +0100 Subject: [PATCH 14/14] NEW: (VarTests) New_Empty & New_T --- Tests/Editor/VarTests.cs | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/Tests/Editor/VarTests.cs b/Tests/Editor/VarTests.cs index cb4b727..2d114bd 100644 --- a/Tests/Editor/VarTests.cs +++ b/Tests/Editor/VarTests.cs @@ -7,6 +7,62 @@ namespace N8.Utils.SOA.Tests.Editor public class VarTests { + /* + [Test] + public void New_Empty() + { + Var __vector3Var = Var.New(); + + Assert.AreEqual( + expected: Vector3.zero, + actual: __vector3Var.Value); + + Assert.AreNotEqual( + expected: Vector3.one, + actual: __vector3Var.Value); + } + + [Test] + public void New_T() + { + Var __vector3Var = Var.New(val: Vector3.one); + + Assert.AreEqual( + expected: Vector3.one, + actual: __vector3Var.Value); + + Assert.AreNotEqual( + expected: Vector3.zero, + actual: __vector3Var.Value); + } + */ + [Test] + public void New_Empty() + { + Vector3Var __vector3Var = Vector3Var.New(); + + Assert.AreEqual( + expected: Vector3.zero, + actual: __vector3Var.Value); + + Assert.AreNotEqual( + expected: Vector3.one, + actual: __vector3Var.Value); + } + + [Test] + public void New_T() + { + Vector3Var __vector3Var = Vector3Var.New(val: Vector3.one); + + Assert.AreEqual( + expected: Vector3.one, + actual: __vector3Var.Value); + + Assert.AreNotEqual( + expected: Vector3.zero, + actual: __vector3Var.Value); + } } } \ No newline at end of file