private static void Process3DAsset(AssetCollection assets, AssetContext assetContext) { new MeshExporter(assets).ExportAsset(assetContext); if (assetContext.Type != typeof(Mesh)) { new PrefabExporter(assets).ExportAsset(assetContext); } }
//[MenuItem("CONTEXT/Terrain/Export Terrain To Urho3D")] //static void ExportTerrain(MenuCommand command) //{ // if (!ResolveDataPath(out var urhoDataPath)) return; //} public static void ExportToUrho(string targetPath, bool overrideFiles, bool exportSelected) { if (string.IsNullOrWhiteSpace(targetPath)) { return; } var urhoDataPath = new DestinationFolder(targetPath, overrideFiles); AssetCollection assets; if (Selection.assetGUIDs.Length == 0 || !exportSelected) { assets = new AssetCollection(urhoDataPath, AssetDatabase.FindAssets("").Select(_ => AssetContext.Create(_, urhoDataPath)) .Where(_ => _.Type != null)); } else { var selectedAssets = new HashSet <string>(); foreach (var assetGuiD in Selection.assetGUIDs) { AddSelection(assetGuiD, selectedAssets); } var enumerable = selectedAssets.Select(_ => AssetContext.Create(_, urhoDataPath)).ToList(); var assetContexts = enumerable.Where(_ => _.Type != null).ToList(); assets = new AssetCollection(urhoDataPath, assetContexts); } _id = 0; var other = Split(assets, _ => _.Is3DAsset, _ => Process3DAsset(assets, _)); var textureMetadataCollection = new TextureMetadataCollection(urhoDataPath); other = Split(other, _ => _.Type == typeof(Texture3D) || _.Type == typeof(Texture2D) || _.Type == typeof(Cubemap), _ => new TextureExporter(assets, textureMetadataCollection).ExportAsset(_)); other = Split(other, _ => _.Type == typeof(Material), _ => new MaterialExporter(assets, textureMetadataCollection).ExportAsset(_)); var activeScene = SceneManager.GetActiveScene(); other = Split(other, _ => _.Type == typeof(SceneAsset), _ => { if (_.AssetPath == activeScene.path) { ProcessSceneAsset(assets, _, activeScene); } }); foreach (var assetContext in other) { ProcessAsset(assets, assetContext); } }
private static void ProcessAsset(AssetCollection assets, AssetContext assetContext) { if (assetContext.Type == typeof(GameObject)) { new PrefabExporter(assets).ExportAsset(assetContext); } else if (assetContext.Type == typeof(SceneAsset)) { //new SceneExporter(assets).ExportAsset(assetContext); } }
private static void Process3DAsset(AssetCollection assets, AssetContext assetContext) { Directory.CreateDirectory(assetContext.ContentFolder); new MeshExporter(assets).ExportAsset(assetContext); if (File.Exists(assetContext.UrhoFileName)) { return; } new PrefabExporter(assets).ExportAsset(assetContext); }
private static void ProcessAsset(AssetCollection assets, AssetContext assetContext) { if (File.Exists(assetContext.UrhoFileName)) { return; } Directory.CreateDirectory(Path.GetDirectoryName(assetContext.UrhoFileName)); if (assetContext.Type == typeof(GameObject)) { new PrefabExporter(assets).ExportAsset(assetContext); } else if (assetContext.Type == typeof(SceneAsset)) { //new SceneExporter(assets).ExportAsset(assetContext); } }
private static void ProcessSceneAsset(AssetCollection assets, AssetContext assetContext, Scene scene) { new SceneExporter(assets).ExportAsset(assetContext, scene); }
public MaterialExporter(AssetCollection assets) : base() { _assets = assets; }
public SceneExporter(AssetCollection assets) : base(assets) { }
private static void ExportToUrho() { string urhoDataPath = EditorUtility.SaveFolderPanel("Save assets to Data folder", _prevFolder, ""); if (string.IsNullOrEmpty(urhoDataPath)) { return; } if (urhoDataPath.StartsWith(Path.GetDirectoryName(Application.dataPath).Replace('\\', '/'), StringComparison.InvariantCultureIgnoreCase)) { EditorUtility.DisplayDialog("Error", "Selected path is inside Unity folder. Please select a different folder.", "Ok"); return; } _prevFolder = urhoDataPath; AssetCollection assets; if (Selection.assetGUIDs.Length == 0) { assets = new AssetCollection(urhoDataPath, AssetDatabase.FindAssets("").Select(_ => AssetContext.Create(_, urhoDataPath)).Where(_ => _.Type != null)); } else { var selectedAssets = new HashSet <string>(); foreach (var assetGuiD in Selection.assetGUIDs) { AddSelection(assetGuiD, selectedAssets); } assets = new AssetCollection(urhoDataPath, selectedAssets.Select(_ => AssetContext.Create(_, urhoDataPath)).Where(_ => _.Type != null)); } _id = 0; //string urhoDataPath = @"C:\Temp\Data\"; //foreach (var type in assets.Select(_ => _.Type).Distinct()) Debug.Log(type.FullName); List <AssetContext> other = Split(assets, _ => _.Is3DAsset, _ => Process3DAsset(assets, _)); other = Split(other, _ => _.Type == typeof(Texture3D) || _.Type == typeof(Texture2D) || _.Type == typeof(Cubemap), _ => new TextureExporter(assets).ExportAsset(_)); other = Split(other, _ => _.Type == typeof(Material), _ => new MaterialExporter(assets).ExportAsset(_)); var activeScene = EditorSceneManager.GetActiveScene(); other = Split(other, _ => _.Type == typeof(SceneAsset), _ => { if (_.AssetPath == activeScene.path) { ProcessSceneAsset(assets, _, activeScene); } }); foreach (var assetContext in other) { ProcessAsset(assets, assetContext); } //foreach (var s in guids2) //{ // var path = AssetDatabase.GUIDToAssetPath(s); // if (path.StartsWith(assetsPrefix)) // { // path = path.Substring(assetsPrefix.Length); // } // if (path.StartsWith("PolygonSciFiCity")) // { // if (path.EndsWith(".prefab", true, CultureInfo.InvariantCulture)) // { // ExportPrefab(s, path, @"C:\Temp\Data\"); // } // if (path.EndsWith(".fbx", true, CultureInfo.InvariantCulture)) // { // ExportModel(s, path, @"C:\Temp\Data\"); // } // if (path.EndsWith(".mat", true, CultureInfo.InvariantCulture)) // { // ExportMaterial(s, path, @"C:\Temp\Data\"); // } // if (path.EndsWith(".png", true, CultureInfo.InvariantCulture) || // path.EndsWith(".dds", true, CultureInfo.InvariantCulture) || // path.EndsWith(".tga", true, CultureInfo.InvariantCulture)) // { // CopyFileIfNew(s, path, @"C:\Temp\Data\"); // } // } //} }
public TextureExporter(AssetCollection assets, TextureMetadataCollection textureMetadata) { _assets = assets; _textureMetadata = textureMetadata; }
public PrefabExporter(AssetCollection assets) : base(assets) { }
public BaseNodeExporter(AssetCollection assets) { _assets = assets; }
public MaterialExporter(AssetCollection assets, TextureMetadataCollection textureMetadataCollection) { _assets = assets; }
public MeshExporter(AssetCollection assetCollection) { _assetCollection = assetCollection; }
public TextureExporter(AssetCollection assets) : base() { _assets = assets; }