[ad_1]
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 enhance 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 want to make use of SerializableQuaternion to put it aside to an area file..
if not it should present error
“”SerializationException: Type ‘UnityEngine.Quaternion’ in Assembly ‘UnityEngine.CoreModule, Version=0.0.0.0, Culture=impartial, PublicKeyToken=null’ will not be marked as serializable.”
I saving like this
BinaryFormatter formatter = new BinaryFormatter();;
FileStream stream = new FileStream(path, FileMode.Create);
savedata information = new savedata();
formatter.Serialize(stream, information);
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);
}
}
[ad_2]