public IUnityAssetDataElement Build(SeldomInterruptChecker seldomInterruptChecker, IPsiSourceFile currentSourceFile, AssetDocument assetDocument) { if (AssetUtils.IsMonoBehaviourDocument(assetDocument.Buffer)) { var anchor = AssetUtils.GetAnchorFromBuffer(assetDocument.Buffer); if (!anchor.HasValue) { return(null); } var dictionary = new Dictionary <string, IAssetValue>(); var entries = assetDocument.Document.FindRootBlockMapEntries()?.Entries; if (entries == null) { return(null); } foreach (var entry in entries) { var key = entry.Key.GetPlainScalarText(); if (key == null || ourIgnoredMonoBehaviourEntries.Contains(key)) { continue; } foreach (var deserializer in myDeserializers) { try { if (deserializer.TryGetInspectorValue(currentSourceFile, entry.Content, out var result)) { dictionary[key] = result; break; } } catch (Exception e) { myLogger.Error(e, "An error occurred while deserializing value {0}", deserializer.GetType().Name); } } } if (dictionary.TryGetValue(UnityYamlConstants.ScriptProperty, out var scriptValue) && scriptValue is AssetReferenceValue referenceValue) { var location = new LocalReference(currentSourceFile.PsiStorage.PersistentIndex, anchor.Value); var script = referenceValue.Reference; var list = new List <InspectorVariableUsage>(); foreach (var(key, value) in dictionary) { list.Add(new InspectorVariableUsage(location, script, key, value)); } var result = new AssetInspectorValuesDataElement(list); return(result); } } return(null); }
private static void Write(UnsafeWriter writer, AssetInspectorValuesDataElement value) { writer.Write(value.VariableUsages.Count); foreach (var v in value.VariableUsages) { writer.WritePolymorphic(v); } }
private static object Read(UnsafeReader reader) { var count = reader.ReadInt32(); var list = new List <InspectorVariableUsage>(count); for (int i = 0; i < count; i++) { list.Add(reader.ReadPolymorphic <InspectorVariableUsage>()); } var importedInspectorValues = ImportedInspectorValues.ReadFrom(reader); var result = new AssetInspectorValuesDataElement(list, importedInspectorValues); return(result); }