Importing an unity package at runtime with script.

Hi,
For our project we want to import an unity package at runtime. We have tried using:

UnityEditor.AssetDatabase.ImportPackage("C:\\Users\\alican\\Documents\\Vuforia\\ModelTargets\\Controller_Model\\dataset\\Controller_Model.unitypackage", false);

But it didn’t work since it is an editor script. Is there any way that we can import unity packages at runtime ? Thanks in advance.

Pretty sure that would be “no,” since there is no compiler or Unity editor to compile the asset into something the built game engine can use, and your user certainly does not have a Unity license to use the code even if you sent it to them.

That said, there are other late-binding script solutions such as LUA, and you can certainly get asset importers to read textures and models at runtime, and there are plenty of tutorials online for all of those.

But once you build a game, UnityEditor is gone.

1 Like

The functionality to import a package is not included in a build. If you want to deliver assets after your game releases, consider using Asset Bundles. If you want to deliver code changes, you can’t for C#. But as already mentioned you can add a runtime interpreted language in your game.