Other conversions may require some medium processing:
UnityEngine.Color32 <-> System.Drawing.Color
Matrix4x4
Matrix4x4 might need to be transposed because M14 maps to m30 in the field layouts. The possible necessity of transposition can be verified with vector math.
Range
Both are the same size, but Unity stores "start" and "length" whereas CoreCLR stores "start" and "end."
Color
The CoreCLR color has a completely different memory layout. Properties and methods must be used to convert.
public static implicit operator UnityEngine.Color32(System.Drawing.Color color)
{
return new UnityEngine.Color32(color.R, color.G, color.B, color.A);
}
public static implicit operator System.Drawing.Color(UnityEngine.Color32 color)
{
return System.Drawing.Color.FromArgb(color.a, color.r, color.g, color.b);
}
It would be convenient to have bidirectional implicit conversions for common mathematical value types.
Some conversions can be done purely with pointers since they contain the same memory layout:
UnityEngine.Vector2
<->System.Numerics.Vector2
UnityEngine.Vector3
<->System.Numerics.Vector3
UnityEngine.Vector4
<->System.Numerics.Vector4
UnityEngine.Quaternion
<->System.Numerics.Quaternion
UnityEngine.Plane
<->System.Numerics.Plane
UnityEngine.Vector2
<->System.Drawing.PointF
UnityEngine.Vector2Int
<->System.Drawing.Point
UnityEngine.Vector2
<->System.Drawing.SizeF
UnityEngine.Vector2Int
<->System.Drawing.Size
UnityEngine.Rect
<->System.Drawing.RectangleF
UnityEngine.RectInt
<->System.Drawing.Rectangle
Other conversions may require some small processing:
UnityEngine.Matrix4x4
<->System.Numerics.Matrix4x4
UnityEngine.RangeInt
<->System.Range
Other conversions may require some medium processing:
UnityEngine.Color32
<->System.Drawing.Color
Matrix4x4
Matrix4x4
might need to be transposed becauseM14
maps tom30
in the field layouts. The possible necessity of transposition can be verified with vector math.Range
Both are the same size, but Unity stores "start" and "length" whereas CoreCLR stores "start" and "end."
Color
The CoreCLR color has a completely different memory layout. Properties and methods must be used to convert.