- Home /
Submitting asset with html/css/javascript files
As the question suggests. I am trying to submit an Asset to the Unity Asset Store. The asset is designed for documentation and generates a HTML/JS/CSS based document for browsers. Since the core template files for document comprises of files including JS I have placed it inside of Streaming Asset folder which stops unity from compiling document JS files. The asset store policy only allows one folder in the root and Streaming Asset directory needs to be on the root to work properly if nested inside of some other folder it will give errors since unity will start compiling files inside of streaming assets. In other words my asset comprises of two folders one is for core logic files and the other is streaming assets folder for the template files. Is there any way around it. So that keeping my current hierarchy I can post the asset on the asset store. Thanks in advance.
Answer by Bunny83 · May 22, 2018 at 10:23 AM
One way would be to "pack" your streaming asset files into your actual asset folder with a different extension and have an editor script which does the extraction after import. I'm not a fan of assets which do things like that but it may be an option. The editor script could in theory delete itself after the copy / move is done, however i would not recommend this.
The general flow would be:
Use InitializeOnLoad and the static constructor to register a method to EditorApplication.update to get an actual callback on the main thread
In your callback check if your files are already extracted and if not, do it right now.
once done make sure you unsubscribe your callback from the update delegate
Note in order to not duplicate your files you have to look "carefully" in the streaming assets folder for your files. Maybe the user has moved them in a subfolder or something like that.
A better alternative would be to ship an editor window which opens up at first start with the same functionality mentioned above and let the user decide to perform the extraction. Add a menu entry for your editor window so if the user doesn't want to do this right now he can do it later.
For development you may also want to create method to actually copy the files into your "single folder".