(int version, Track track, BinaryReader stream)
| 39 | } |
| 40 | |
| 41 | private static void LoadTrack(int version, Track track, BinaryReader stream) |
| 42 | { |
| 43 | var e = (EventTrack)track; |
| 44 | |
| 45 | var paramsCount = stream.ReadInt32(); |
| 46 | e.EventParamsSizes = new int[paramsCount]; |
| 47 | e.EventParamsTypes = new Type[paramsCount]; |
| 48 | int eventsCount = stream.ReadInt32(); |
| 49 | e.MemberName = LoadName(stream); |
| 50 | |
| 51 | bool isInvalid = false; |
| 52 | for (int i = 0; i < paramsCount; i++) |
| 53 | { |
| 54 | e.EventParamsSizes[i] = stream.ReadInt32(); |
| 55 | var paramTypeName = LoadName(stream); |
| 56 | e.EventParamsTypes[i] = TypeUtils.GetManagedType(paramTypeName); |
| 57 | if (e.EventParamsTypes[i] == null) |
| 58 | { |
| 59 | Editor.LogError($"Unknown type {paramTypeName}."); |
| 60 | isInvalid = true; |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | if (isInvalid) |
| 65 | { |
| 66 | e.Events.ResetKeyframes(); |
| 67 | stream.ReadBytes(eventsCount * (sizeof(float) + e.EventParamsSizes.Sum())); |
| 68 | Editor.LogError("Cannot load track " + e.MemberName + " of type " + e.MemberTypeName + ". Failed to find the value type information."); |
| 69 | return; |
| 70 | } |
| 71 | |
| 72 | e.OnEventParamsChanged(); |
| 73 | |
| 74 | var events = new KeyframesEditor.Keyframe[eventsCount]; |
| 75 | var dataBuffer = paramsCount != 0 ? new byte[e.EventParamsSizes.Max()] : null; |
| 76 | GCHandle handle = paramsCount != 0 ? GCHandle.Alloc(dataBuffer, GCHandleType.Pinned) : new GCHandle(); |
| 77 | for (int i = 0; i < eventsCount; i++) |
| 78 | { |
| 79 | var time = stream.ReadSingle(); |
| 80 | |
| 81 | var key = new EventKey |
| 82 | { |
| 83 | Parameters = new object[paramsCount] |
| 84 | }; |
| 85 | |
| 86 | for (int j = 0; j < paramsCount; j++) |
| 87 | { |
| 88 | stream.Read(dataBuffer, 0, e.EventParamsSizes[j]); |
| 89 | key.Parameters[j] = Utilities.Utils.ByteArrayToStructure(handle.AddrOfPinnedObject(), e.EventParamsTypes[j], e.EventParamsSizes[j]); |
| 90 | } |
| 91 | |
| 92 | events[i] = new KeyframesEditor.Keyframe |
| 93 | { |
| 94 | Time = time, |
| 95 | Value = key, |
| 96 | }; |
| 97 | } |
| 98 | if (handle.IsAllocated) |
nothing calls this directly
no test coverage detected