I have a custom data type I made called a point.
It has implicit operators to easily convert between a Vector3 and a float[], the reason being Vector3 and Vector2 types are not System.Serializable meaning they cant be converted to binary, before I would use a simple method like this:
public static void Vector3ToFloatArray(Vector3 v) { return new float[] {v.x, v.y, v.z}; } And another for float[] to Vector3
Here is the code I made for my custom point data type:
using System; using UnityEngine; [Serializable] public struct Point { public float x, y, z; public Point(float x, float y, float z) { this.x = x; this.y = y; this.z = z; } public static implicit operator Vector3(Point p) => new(p.x, p.y, p.z); public static implicit operator float[](Point p) => new float[] {p.x, p.y, p.z}; public static implicit operator Point(Vector3 v) => new(v.x, v.y, v.z); public static implicit operator Point(float[] f) { if (f.Length != 3) throw new ArgumentException("Float array must have exactly 3 elements for point conversion."); return new Point(f[0], f[1], f[2]); } public bool IsZero { get { if (x == 0 && y == 0 && z == 0) return true; return false; } } } As you can see I have an operator for converting from Point to float array and the other way around. Yet in Unity it says:
It claims a Single[] can't be converted into a 'Point' even though I have the implicit operator in place.
The 'position' variable it's referring to is inside my SaveData script:
using UnityEngine; namespace Game.Save { [System.Serializable] public class SaveData { public int MusicIndex { get; set; } = 0; public Point position; // TEMPORARY public SaveData(Vector3 pos, int musicDex) { position = pos; } } } As you can see inside the constructer I'm able to set position to a Vector3 due to that implicit operator, so I should be able to convert a float array into it and I don't understand why it's throwing this error.
Edit: I forgot to mention the reason the error is for "point" and the struct is called "Point" is because after the error threw I also did some code optimization like making point capitalized. The new error looks like this:


pointwith a lower case "p". Your struct has an upper case "P". Note that C# is case sensitive. Is there another type calledpointsomewhere? Or maybe you renamed it and there is still an older version stored somewhere? \$\endgroup\$implicit operator Point(float[] f)to see whether it is called and then single step throught it? And also a breakpoint where you think this conversion is called. \$\endgroup\$SaveSlot slotResult = formatter.Deserialize(slotStream) as SaveSlot;the 'SaveSlot' contains a 'SaveData', which contains the 'position' Point variable. \$\endgroup\$[]operator? (Or rely on implicit conversion toVector3to lean on its implementation?) \$\endgroup\$