diff --git a/LibBSP/Source/Extensions/UIVertexExtensions.cs b/LibBSP/Source/Extensions/UIVertexExtensions.cs
index c4cb507..ccead1d 100644
--- a/LibBSP/Source/Extensions/UIVertexExtensions.cs
+++ b/LibBSP/Source/Extensions/UIVertexExtensions.cs
@@ -21,15 +21,14 @@ namespace LibBSP {
///
public static class UIVertexExtensions {
+#if !UNITY
///
/// Scales the position of this by a number.
///
/// This .
/// Scalar value.
- /// The scaled .
- public static UIVertex Scale(this UIVertex v1, float scalar) {
+ public static void Scale(this ref UIVertex v1, float scalar) {
v1.position *= scalar;
- return v1;
}
///
@@ -37,16 +36,10 @@ namespace LibBSP {
///
/// This .
/// The other .
- /// The resulting .
- public static UIVertex Add(this UIVertex v1, UIVertex v2) {
- return new UIVertex {
- color = v1.color,
- normal = v1.normal,
- position = v1.position + v2.position,
- tangent = v1.tangent,
- uv0 = v1.uv0 + v2.uv0,
- uv1 = v1.uv1 + v2.uv1
- };
+ public static void Add(this ref UIVertex v1, UIVertex v2) {
+ v1.position += v2.position;
+ v1.uv0 += v2.uv0;
+ v1.uv1 += v2.uv1;
}
///
@@ -54,16 +47,47 @@ namespace LibBSP {
///
/// This .
/// The .
- /// The resulting .
- public static UIVertex Translate(this UIVertex v1, Vector3 v2) {
- return new UIVertex {
- color = v1.color,
- normal = v1.normal,
- position = v1.position + v2,
- tangent = v1.tangent,
- uv0 = v1.uv0,
- uv1 = v1.uv1
- };
+ public static void Translate(this ref UIVertex v1, Vector3 v2) {
+ v1.position += v2;
+ }
+#endif
+
+ // Extension methods using "ref" are features of C# 7.2. They will not work in Unity, no matter what.
+ // Instead use these vanilla static methods in any code intended to be used with Unity.
+
+ ///
+ /// Scales the position of a by a number and returns the result.
+ ///
+ /// The to scale.
+ /// Scalar value.
+ /// The resulting of this scaling operation.
+ public static UIVertex Scale(UIVertex v1, float scalar) {
+ v1.position *= scalar;
+ return v1;
+ }
+
+ ///
+ /// Adds the position of a to another and returns the result.
+ ///
+ /// A to be added to another.
+ /// A to be added to another.
+ /// The resulting of this addition.
+ public static UIVertex Add(UIVertex v1, UIVertex v2) {
+ v1.position += v2.position;
+ v1.uv0 += v2.uv0;
+ v1.uv1 += v2.uv1;
+ return v1;
+ }
+
+ ///
+ /// Adds the position of a Vector3 to a and returns the result.
+ ///
+ /// The to translate.
+ /// The to translate by.
+ /// The resulting translated by .
+ public static UIVertex Translate(UIVertex v1, Vector3 v2) {
+ v1.position += v2;
+ return v1;
}
///