You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Variable System - Introduce CloningTools for deep cloning of variables
This commit adds a new CloningTools class to facilitate deep cloning of variable types, ensuring proper handling of value types, reference types, and collections. Additionally, it updates the ReferenceBase and VariableBaseSO classes to utilize the new cloning functionality for inlined values and default values.
Copy file name to clipboardExpand all lines: Runtime/Base/ReferenceBase.cs
+7-2Lines changed: 7 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,14 @@
5
5
usingSystem;
6
6
usingUnityEngine.Events;
7
7
usingXprees.Core;
8
+
usingXprees.Variables.Utils;
8
9
9
10
namespaceXprees.Variables.Base
10
11
{
12
+
/// <summary>
13
+
/// Base class for all variable references used in the game. It can either use an inlined value or reference a VariableBaseSO Scriptable Object. The Value property abstracts this choice away, so users of ReferenceBase don't have to care about it.
/// Helper to clone a value of type T. It handles value types, reference types that implement ICloneable, and other reference types by serializing and deserializing them using Unity's JsonUtility. Note that the serialization approach only works for types that are compatible with JsonUtility (e.g., they must be Unity serializable). For more complex types, you might need to implement custom cloning logic or use a different serialization method.
// Value types can be returned directly since they are copied by value. However, we can optimize for value types that do not contain references to avoid unnecessary cloning.
0 commit comments