Quantcast
Channel: Answers by "PokeJoe"
Viewing all articles
Browse latest Browse all 8

Answer by PokeJoe

$
0
0
In case any one comes along with this problem in the future, I figured it out. In the second parameter, I use `items[0].name`. In the case of most objects, this is fine because it contains the name of the object excluding any subdirectories it's in. However, in the case of shaders, it contains the display name of the shader, as you select it from the list when making a material. This is NOT the same as the name of the asset in the project. For example, I made a shader called VarBrush.shader, which is listed in the menus as Outlined/VarBrush. The problem is, its .name property is "Outlined/VarBrush". When exporting, Unity chokes on trying to put a slash in the filename (it won't create nonexsting directories from a specified file path). This is why the error is in copying it from Unity's temporary packaging directory into my specified filename. My solution: string namesan = items[0].name.Replace('\\', '_').Replace('/','_'); //Sanitize slashes in name AssetDatabase.ExportPackage(AssetDatabase.GetAssetPath(items[0]), "C:\\path\\" + namesan + ".unitypackage", ExportPackageOptions.IncludeDependencies);

Viewing all articles
Browse latest Browse all 8

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>