MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / GetAttributes

Method GetAttributes

Source/Editor/Surface/SurfaceMeta.cs:58–95  ·  view source on GitHub ↗

Gets the attributes collection from the data. The graph metadata serialized with JsonSerializer. The graph metadata serialized with BinaryFormatter. The attributes collection.

(byte[] data, byte[] oldData)

Source from the content-addressed store, hash-verified

56 /// <param name="oldData">The graph metadata serialized with BinaryFormatter.</param>
57 /// <returns>The attributes collection.</returns>
58 public static Attribute[] GetAttributes(byte[] data, byte[] oldData)
59 {
60 if (data != null && data.Length != 0)
61 {
62 try
63 {
64 var json = Encoding.Unicode.GetString(data);
65 return FlaxEngine.Json.JsonSerializer.Deserialize<Attribute[]>(json);
66 }
67 catch (Exception ex)
68 {
69 Editor.LogError("Failed to deserialize Visject attributes array.");
70 Editor.LogWarning(ex);
71 }
72 }
73 if (oldData != null && oldData.Length != 0)
74 {
75 // [Deprecated on 8.12.2023, expires on 8.12.2025]
76 using (var stream = new MemoryStream(oldData))
77 {
78 try
79 {
80 // Ensure we are in the correct load context (https://github.com/dotnet/runtime/issues/42041)
81 using var ctx = AssemblyLoadContext.EnterContextualReflection(typeof(Editor).Assembly);
82#pragma warning disable SYSLIB0011
83 var formatter = new BinaryFormatter();
84 return (Attribute[])formatter.Deserialize(stream);
85#pragma warning restore SYSLIB0011
86 }
87 catch (Exception ex)
88 {
89 Editor.LogError("Failed to deserialize Visject attributes array.");
90 Editor.LogWarning(ex);
91 }
92 }
93 }
94 return Utils.GetEmptyArray<Attribute>();
95 }
96
97 /// <summary>
98 /// Serializes surface attributes into byte[] data using the current format.

Callers 15

GraphParameterDataMethod · 0.45
InitGraphParametersMethod · 0.45
InitializeMethod · 0.45
ToStringMethod · 0.45
OnEditAttributesMethod · 0.45
GetEntriesMethod · 0.45
GetTooltipMethod · 0.45
TypeItemViewMethod · 0.45
TypeSearchPopupMethod · 0.45
RefreshActorTabsMethod · 0.45

Calls 6

GetEntryFunction · 0.85
GetStringMethod · 0.45
LogErrorMethod · 0.45
LogWarningMethod · 0.45
DeserializeMethod · 0.45
GetMetaDataMethod · 0.45

Tested by

no test coverage detected