Skip to content

Commit 4567c5a

Browse files
TORRENS_PHD_ACCOUNTTORRENS_PHD_ACCOUNT
authored andcommitted
somewhat updated README. Still needs to be updated further
1 parent 73564ae commit 4567c5a

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# UnityEditorUtils
1+
# UnityUtils
22

33
_A collection of helpful Unity scripts and editor tools, purely for convenience._
44

@@ -11,7 +11,7 @@ _**Source:** [FuzzyLogic's answer in the Unity forums](https://discussions.unity
1111
To convert any field into a ReadOnly column:
1212

1313
````csharp
14-
[ReadOnly] public float example;
14+
[ReadOnlyInsp] public float example;
1515
````
1616

1717
## Help Box
@@ -39,4 +39,19 @@ You can add an optional parameter that changes the icon that appears with the he
3939
[Help("This is some help text!", UnityEditor.MessageType.None)]
4040
#endif
4141
public float example = 1000f;
42-
````
42+
````
43+
44+
## Serializables
45+
46+
Extension Functions for various Unity-specific class types such as `Vector2` and `Vector3`. These scripts focus on creating `SVector2`, `SVector3`, and `SQuaternion` equivalents of primitive Unity `Vector2`, `Vector3`, and `Quaternion` classes for use in CSV-writing and such, as the primitive classes are not serializable for JSON or CSV reading/writing.
47+
48+
The existing list of serialized equivalents of primitive Unity classes are:
49+
50+
* `Vector2` => `SVector2`
51+
* `Vector3` => `SVector3`
52+
* `Vector4` => `SVector4`
53+
* `Quaternion` => `SQuaternion`
54+
* `Color32` => `SColor32`
55+
* `RaycastHit` => `SRaycastHit`
56+
57+
To use these serialized equivalents, you must import the namespace `using SerializableTypes`.

Serializables/SerializableTypes.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ public static implicit operator SVector2(Vector2 v)
4242

4343
public static SVector2 operator /(SVector2 a, float d)
4444
=> new SVector2(a.x / d, a.y / d);
45+
46+
public float magnitude {
47+
get { return (float)Mathf.Sqrt(this.x * this.x + this.y * this.y); }
48+
}
4549
}
4650

4751
/// <summary> Serializable version of UnityEngine.Vector3. </summary>

0 commit comments

Comments
 (0)