- Home /
import package with script
hi guys, i want to import a unitypackage to my project. i use this code:
AssetDatabase.ImportPackage(Application.dataPath+"/package.unitypackage",true);
but Nothing is added to the project
Answer by dorpeleg · Dec 31, 2012 at 03:53 PM
This is taken from the documentation:
Note: This is an editor class. To use it you have to place your script in Assets/Editor inside your project folder. Editor classes are in the UnityEditor namespace so for C# scripts you need to add "using UnityEditor;" at the beginning of the script.
It means this is an editor script, not something you can use at run-time.
If you are using it in editor, then there might be something wrong with your path.
in my project this path exist: Assets/Standard Assets/Editor
I think you didn't understand. The script you made that is running the ImportPackage line, needs to be located in /Editor for it to work. This means it can only be run trough the editor and not during gameplay. Is that what you are doing?
@nishatj no, if you want to load stuff at runtime, use asset bundles.
Your answer
Follow this Question
Related Questions
Running AssetDatabase.ImportPackage on multiple packages 3 Answers
share or reassign materials 0 Answers
Custom Fonts... Missing on friend's computer 1 Answer
Maya Import Strip Namespaces 6 Answers
Import text into unity 2 Answers