public UnityDumper(string path = null, bool assemblyNameAsSubfolder = true) { sb.AppendLine(@"%YAML 1.1 %TAG !u! tag:unity3d.com,2011:"); if (!string.IsNullOrEmpty(path)) { if (!ForceOverwriteCSharpFiles) { RefreshGuidsUsingEvilHack(path); } dumper = new CSharpDumper(ForceOverwriteCSharpFiles ? (ICollection <Type>) new List <Type>() : MonoBehaviourGuids.Keys, path, assemblyNameAsSubfolder); meshDumper = new MeshDumper(Path.Combine(path, "models")); textureDumper = new TextureDumper(Path.Combine(path, "textures")); materialDumper = new MaterialDumper(this, Path.Combine(path, "materials"), textureDumper); prefabPath = Path.Combine(path, "prefabs"); if (!Directory.Exists(prefabPath)) { Directory.CreateDirectory(prefabPath); } } jsonSettings = new JsonSerializerSettings() { ContractResolver = new UnitySerializedContractResolver() }; jsonSettings.Converters.Add(new AnimationCurveConverter()); jsonSettings.Converters.Add(new UnityObjectTracker(this)); jsonSettings.Converters.Add(new BoolConverter()); }
internal static void RefreshGuidsUsingEvilHack(string directory) { foreach (var file in Directory.GetFiles(directory, "*.cs", SearchOption.AllDirectories)) { if (CSharpDumper.TryGetGuid(file, out var guid, out var type)) { MonoBehaviourGuids[type] = guid; } } }