|
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?
(comments are locked)
|
|
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. Thanks for your reply! I wouldn't at all mind Unity breaking my code some time in the future - this will be a nothing more than a component of an easy-to-distribute Editor plugin, and obscurity doesn't scare me :) I have no idea how to go about using reflection, so I may have to give up on the idea for now - but if anyone would like to point my researches in the right direction, I would be most grateful.
May 03 '10 at 03:58 PM
Aubrey Falconer
(comments are locked)
|
|
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. It brings me great pain that something as powerful as the Unity editor would have to be controlled through windows API scripting - but you're right, this may indeed be our only option at this time.
Dec 31 '10 at 06:54 AM
Aubrey Falconer
(comments are locked)
|

@Aubrey, remember to upvote good answers (and checkmark the correct one).
Hi, doing so would be very interesting! Have you ever managed to implement it?
Allright ladies and gentlemen ~ Unity 3 has come, and it has disabled reflection and added cool new API tools. I a more interested than ever in creating asset packages programatically, so please have at the bounty!
Bounty ends tomorrow, everyone's suggestions are welcome
this is still only possible with the PRO editions of Unity3D, right?