public override void Export(AssetDatabaseBuilder builder, Object target) { var behaviour = target as MonoBehaviour; var type = behaviour.GetType(); var asset = Resources.Load(type.Name); var fileId = asset.GetLocalFileId(); if (builder.ContainsFileId(fileId)) { return; } builder.WriteHeader <MonoBehaviour>(fileId); builder.WriteProperty("name", behaviour.GetType().Name); builder.WriteProperty("ext", ".cs"); builder.FileIds.Add(fileId); }
private void ExportTexture(AssetDatabaseBuilder builder, Material material) { var texture = material.mainTexture; if (texture == null) { return; } var textureFileId = texture.GetLocalFileId(); if (builder.ContainsFileId(textureFileId)) { return; } var path = AssetDatabase.GetAssetPath(texture); var ext = Path.GetExtension(path); path = PathEx.GetPathWithoutExtension(path); builder.WriteHeader <Texture>(textureFileId); builder.WriteProperty("name", texture.name); builder.WriteProperty("path", path); builder.WriteProperty("ext", ext); var materialFileId = material.GetLocalFileId(); if (builder.ContainsFileId(materialFileId)) { return; } builder.WriteHeader <Material>(materialFileId); builder.WriteProperty("name", material.name); builder.WriteFileIdProperty("texture", textureFileId); builder.FileIds.Add(textureFileId); builder.FileIds.Add(materialFileId); }
public override void Export(AssetDatabaseBuilder builder, Object target) { var meshFilter = target as MeshFilter; var mesh = meshFilter.sharedMesh; var fileId = mesh.GetLocalFileId(); if (builder.ContainsFileId(fileId)) { return; } var path = AssetDatabase.GetAssetPath(mesh); var ext = Path.GetExtension(path); path = PathEx.GetPathWithoutExtension(path); builder.WriteHeader <Mesh>(fileId); builder.WriteProperty("name", mesh.name); builder.WriteProperty("path", path); builder.WriteProperty("ext", ext); builder.FileIds.Add(fileId); }