//--------------- SERIALIZE -------------------- //--------------- DESERIALIZE -------------------- public static ExposedCollection[] Deserialize(byte[] input) { if (input == null) return null; ComposedByteStream stream = ComposedByteStream.FromByteArray(input); if (stream == null) return null; int iMax = stream.streamCount; ExposedCollection[] result = new ExposedCollection[iMax]; for (int i = 0; i < iMax; i++) { ExposedCollection coll = new ExposedCollection(); byte[] subStreamBytes = stream.ReadNextStream<byte>(); if (subStreamBytes == null || subStreamBytes.Length == 0) continue; ComposedByteStream subStream = ComposedByteStream.FromByteArray(subStreamBytes); coll.fieldName = subStream.ReadNextStream(); coll.typeName = subStream.ReadNextStream(); coll.primitiveValues = SerializeSharedHelper.DeserializeStrings(subStream.ReadNextStream<byte>()); coll.objectValues = ExposedObject.DeserializeArray(subStream.ReadNextStream<byte>()); coll.unityObjectValues = ExposedUnityObjectPointer.DeserializeArray(subStream.ReadNextStream<byte>()); subStream.Dispose(); result[i] = coll; } stream.Dispose(); return result; }
//--------------- SERIALIZE -------------------- public static byte[] SerializeArray(ExposedCollection[] input) { if (input == null) return null; int iMax = input.Length; ComposedByteStream stream = ComposedByteStream.FetchStream(iMax); for (int i = 0; i < iMax; i++) stream.AddStream(Serialize(input[i])); return stream.Compose(); }
public static byte[] Serialize(ExposedCollection input) { if (input == null) return null; ComposedByteStream stream = ComposedByteStream.FetchStream(); stream.AddStream(input.fieldName); stream.AddStream(input.typeName); stream.AddStream(SerializeSharedHelper.SerializeStrings(input.primitiveValues)); stream.AddStream(ExposedObject.SerializeArray(input.objectValues)); stream.AddStream(ExposedUnityObjectPointer.SerializeArray(input.unityObjectValues)); return stream.Compose(); }
private void DrawCollections(string id, ExposedCollection[] collections, int depth) { if (collections == null || collections.Length == 0) return; id += "_coll_"; for (int i = 0; i < collections.Length; i++) { ExposedCollection coll = collections[i]; if (coll == null) continue; id += i; if (!inspectorFoldoutStates.ContainsKey(id)) inspectorFoldoutStates.Add(id, false); GUILayout.BeginHorizontal(); GUILayout.Space(depth * depthSpacing); GUILayout.BeginVertical(); if (inspectorFoldoutStates[id] = EditorGUILayout.Foldout(inspectorFoldoutStates[id], coll.fieldName, EditorHelper.styleHierarchyFoldout)) { if (coll.primitiveValues != null && coll.primitiveValues.Length > 0) { DrawSizes(coll.primitiveValues.Length, 1); DrawPrimitivesCollumn(coll.primitiveValues, 1, true); } else if (coll.objectValues != null && coll.objectValues.Length > 0) { DrawSizes(coll.objectValues.Length, 1); DrawObjects(id, coll.objectValues, 1, "Element " + i); } else if (coll.unityObjectValues != null && coll.unityObjectValues.Length > 0) { DrawSizes(coll.unityObjectValues.Length, 1); DrawUnityObjectPointer(coll.unityObjectValues, 1, true); } } GUILayout.EndVertical(); GUILayout.EndHorizontal(); } }