private void DrawUnityObjectPointer(ExposedUnityObjectPointer[] objects, int depth, bool drawIdx = false) { if (objects == null || objects.Length == 0) return; for (int i = 0; i < objects.Length; i++) { ExposedUnityObjectPointer obj = objects[i]; if (obj == null) continue; GUILayout.BeginHorizontal(); GUILayout.Space(depth * depthSpacing); if (drawIdx) GUILayout.Label("Element " + i, EditorHelper.styleLabelLightGray10, GUILayout.Width(100)); if (!string.IsNullOrEmpty(obj.fieldName)) GUILayout.Label(obj.fieldName, EditorHelper.styleLabelLightGray10, GUILayout.Width(100)); GUILayout.Label(obj.objectName, EditorHelper.styleLabelLightGray10, GUILayout.Height(16)); GUILayout.EndHorizontal(); } }
//--------------- Serialize -------------------- public static byte[] SerializeArray(ExposedUnityObjectPointer[] input) { if (input == null) return null; int iMax = input.Length; ComposedByteStream stream = ComposedByteStream.FetchStream(iMax); for (int i = 0; i < iMax; i++) { if (input[i] == null) { stream.AddEmptyStream(); } else { stream.AddStream(Serialize(input[i])); } } return stream.Compose(); }
//--------------- Serialize -------------------- //--------------- Deserialize -------------------- public static ExposedUnityObjectPointer[] DeserializeArray(byte[] input) { if (input == null) return null; ComposedByteStream stream = ComposedByteStream.FromByteArray(input); if (stream == null) return null; int iMax = stream.streamCount; ExposedUnityObjectPointer[] result = new ExposedUnityObjectPointer[iMax]; for (int i = 0; i < iMax; i++) result[i] = Deserialize(stream.ReadNextStream<byte>()); stream.Dispose(); return result; }
public static byte[] Serialize(ExposedUnityObjectPointer input) { ComposedByteStream stream = new ComposedByteStream(3); stream.AddStream(input.fieldName); stream.AddStream(BitConverter.GetBytes(input.instanceID)); stream.AddStream(input.objectName); stream.AddStream(input.typeName); return stream.Compose(); }
public static ExposedUnityObjectPointer Deserialize(byte[] input) { if (input == null || input.Length == 0) return null; ComposedByteStream stream = ComposedByteStream.FromByteArray(input); if (stream == null || stream.streamCount < 3) return null; ExposedUnityObjectPointer result = new ExposedUnityObjectPointer(); result.fieldName = stream.ReadNextStream(); result.instanceID = BitConverter.ToInt32(stream.ReadNextStream<byte>(), 0); result.objectName = stream.ReadNextStream(); result.typeName = stream.ReadNextStream(); stream.Dispose(); return result; }