I would like to save the currently open scene file and all it's dependencies to a Unity Asset Package (.unitypackage) file from an Editor script.
It seems that this topic has been previously broached at http://answers.unity3d.com/questions/3237/export-files-to-a-unitypackage-file-from-c , but I am posting anew to include some more ideas on the subject.
Here's a screenshot from MonoDevelop which shows some interesting functions in Unity's dll file: http://img72.imageshack.us/img72/3380/screenshot20100501at556.png
And here's some code I wrote that serves to illustrate my purpose:
The code currently returns an "'AssetServer' is not a member of 'UnityEditor'" error when compiling.
Mike_Mac said that this was because the function I need to call is a private one, internal to Unity - but that I might be able to access it through reflection.
Anyone have some ideas on how this could be accomplished?
asked May 02 '10 at 01:47 AM
Internal things in UnityEditor/UnityEngine are internal for one of a few reasons: - it doesn't work - it only works if you use it in a very obscure way - we want to be able to change it later without breaking your game - it has some sort of security risk - we didn't realize you might actually want it
That said, you can use reflection to try to call it, but you'd be walking on very thin ice.
answered May 02 '10 at 09:56 PM
Lucas Meijer 1 ♦♦
This might be cheesy, but what if you used Windows API functions (SendMessage and such)? Get the window handle and send the menu code that simulates you choosing the menu item.
answered Dec 31 '10 at 05:00 AM