- Home /
Importing unitypackage while running game
I'm trying to import a unitypackage file using AssetDatabase.ImportPackage.
This is what I want it to be
during game play;
Click a button
call AssetDatabase.ImportPackage();
Import unitypackage
but when I click the button, I only can hear beep sound(like windows warning sound effect), and unitypackage file wasn't imported.
The issue can not be path, because I put unitypackage file in Asstes folder, and the function looks like this.
AssetDatabase.ImportPackage(Applicaion.dataPath, true);
please give me any clue.
Note that if by chance you get this working (which I doubt), it will not in a build. The AssetDatabase class is Editor only. If you have Pro, consider AssetBundle.
http://docs.unity3d.com/$$anonymous$$anual/AssetBundlesIntro.html
wow.. I didn't know that it works only in the editor... Thanks robertbu. I'm not using Pro, but your answer was very helpful for me.
Just a hint, look where the API is documented, it's in a section called UnityEditor. These APIs are editor only.
Your answer
Follow this Question
Related Questions
How to fix error : Unable to update following assemblies:Assets/Plugins/Example.dll 1 Answer
Losing package references between opening/closing project 0 Answers
Correct Way of Exporting Packages 1 Answer
Import unitypackages problem 0 Answers
packaging completed assets to simplify change management 1 Answer