So here’s what’s going on:
When Unity stores a array of ints, it packs them into a long string.
I tried six ways from Tuesday to get the YAML to break them out, but it packed it no matter what I did… and in a way it makes perfect sense… when I put in 1, 2, 3, 4, 5 as the elements, the resulting value was
ints: 0100000002000000030000000400000005000000
So here’s what I did to get these results:
using UnityEngine;
[CreateAssetMenu(fileName = "TestArray", menuName = "Test Array")]
public class ScriptableArray : ScriptableObject
{
[SerializeField] private int[] ints;
[SerializeField] float[] floats;
}
resulted in
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1e1ce10ae35905446b35c99add50d25b, type: 3}
m_Name: TestArray
m_EditorClassIdentifier:
ints: 0100000002000000030000000400000005000000
floats:
- 1
- 2
- 3
- 4
- 5
With some further testing, playing around with the values, the ints are packed as LittleEndian Hexadecimal numbers… so, for example, 169 becomes a9000000 and 256 becomes 00010000.
(Little Endian is where the least significant byte is put first and the most significant byte is last). A packed int string then would simply have to divide the number of characters in the string by 8 and unpack each one as a value by converting them from a hex string to an int.