static void ExtractMaterialsAndTextures(ScriptedImporter self) { if (string.IsNullOrEmpty(self.assetPath)) { return; } Action <Texture2D> addRemap = externalObject => { self.AddRemap(new AssetImporter.SourceAssetIdentifier(typeof(UnityEngine.Texture2D), externalObject.name), externalObject); }; Action <IEnumerable <string> > onCompleted = _ => { AssetDatabase.ImportAsset(self.assetPath, ImportAssetOptions.ForceUpdate); self.ExtractMaterials(); AssetDatabase.ImportAsset(self.assetPath, ImportAssetOptions.ForceUpdate); }; TextureExtractor.ExtractTextures(self.assetPath, GltfTextureEnumerator.Enumerate, self.GetSubAssets <UnityEngine.Texture2D>(self.assetPath).ToArray(), addRemap, onCompleted ); }
static void ExtractMaterialsAndTextures(ScriptedImporter self, GltfParser parser) { if (string.IsNullOrEmpty(self.assetPath)) { return; } Action <Texture2D> addRemap = externalObject => { self.AddRemap(new AssetImporter.SourceAssetIdentifier(typeof(UnityEngine.Texture2D), externalObject.name), externalObject); }; Action <IEnumerable <UnityPath> > onCompleted = _ => { AssetDatabase.ImportAsset(self.assetPath, ImportAssetOptions.ForceUpdate); self.ExtractMaterials(); AssetDatabase.ImportAsset(self.assetPath, ImportAssetOptions.ForceUpdate); }; var assetPath = UnityPath.FromFullpath(parser.TargetPath); var dirName = $"{assetPath.FileNameWithoutExtension}.Textures"; TextureExtractor.ExtractTextures(parser, assetPath.Parent.Child(dirName), GltfTextureEnumerator.Enumerate, self.GetSubAssets <UnityEngine.Texture2D>(self.assetPath).ToArray(), addRemap, onCompleted ); }
static void ExtractMaterialsAndTextures(ScriptedImporter self, GltfParser parser, EnumerateAllTexturesDistinctFunc enumTextures, Func <string, string> textureDir, Func <string, string> materialDir) { if (string.IsNullOrEmpty(self.assetPath)) { return; } Action <SubAssetKey, Texture2D> addRemap = (key, externalObject) => { self.AddRemap(new AssetImporter.SourceAssetIdentifier(key.Type, key.Name), externalObject); }; Action <IEnumerable <UnityPath> > onCompleted = _ => { AssetDatabase.ImportAsset(self.assetPath, ImportAssetOptions.ForceUpdate); self.ExtractMaterials(materialDir); AssetDatabase.ImportAsset(self.assetPath, ImportAssetOptions.ForceUpdate); }; var assetPath = UnityPath.FromFullpath(parser.TargetPath); var dirName = textureDir(assetPath.Value); // $"{assetPath.FileNameWithoutExtension}.Textures"; TextureExtractor.ExtractTextures(parser, assetPath.Parent.Child(dirName), enumTextures, self.GetSubAssets <UnityEngine.Texture2D>(self.assetPath).ToArray(), addRemap, onCompleted ); }