Exemple #1
0
        //[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);
            }
        }
Exemple #2
0
 public TextureExporter(AssetCollection assets, TextureMetadataCollection textureMetadata)
 {
     _assets          = assets;
     _textureMetadata = textureMetadata;
 }
Exemple #3
0
 public MaterialExporter(AssetCollection assets, TextureMetadataCollection textureMetadataCollection)
 {
     _assets = assets;
 }