My three dimensional array is getting so sluggish after I assign one other array to it.
SerializableQuaternion
is a customized kind for saving, so it is totally different from Quaternion.
Is there a greater solution to improve the copy efficiency?
var anro = new Quaternion[60,60,60];
An = new SerializableQuaternion[anro.GetLength(0), anro.GetLength(1), anro.GetLength(2)];
saveIndex = new int[sIn.Length];
if (anro != null)
{
for (int a = 0; a < anro.GetLength(0); a++)
{
for (int b = 0; b < anro.GetLength(1); b++)
{
for (int c = 0; c < anro.GetLength(2); c++)
{
An[a, b, c] = anro[a, b, c];
}
}
}
}
I keep in mind I would like to make use of SerializableQuaternion to reserve it to an area file..
if not it should present error
“”SerializationException: Kind ‘UnityEngine.Quaternion’ in Meeting ‘UnityEngine.CoreModule, Model=0.0.0.0, Tradition=impartial, PublicKeyToken=null’ is just not marked as serializable.”
I saving like this
BinaryFormatter formatter = new BinaryFormatter();;
FileStream stream = new FileStream(path, FileMode.Create);
savedata knowledge = new savedata();
formatter.Serialize(stream, knowledge);
my customized kind
[System.Serializable]
public struct SerializableQuaternion
{
public float x;
public float y;
public float z;
public float w;
public SerializableQuaternion(float rX, float rY, float rZ, float rW)
{
x = rX;
y = rY;
z = rZ;
w = rW;
}
public override string ToString()
{
return String.Format("[{0}, {1}, {2}, {3}]", x, y, z, w);
}
public static implicit operator Quaternion(SerializableQuaternion rValue)
{
return new Quaternion(rValue.x, rValue.y, rValue.z, rValue.w);
}
public static implicit operator SerializableQuaternion(Quaternion rValue)
{
return new SerializableQuaternion(rValue.x, rValue.y, rValue.z, rValue.w);
}
}