- Home /
Loading Scripts through System.IO
hello,
i had an idea om how to enable mods, i want to have folders created in game which then adds the scripts in each file like this : C:/Game/Scripts/weapons as an example, i know how to do it with gameobjects to instantiate, but does anyone know where i can find how to load scripts from files such as this, i was thinking to use stream reader but i don't know how to make that get added into the script. Anyhelp?
Do you know the name of the script/class you're trying to access? In that case you can use
gameObject.AddComponent<Weapons> ();
and if class "Weapons" exists as a script (i.e. weapons.cs) somewhere in your project it'll attach that script to the specified gameobject.
You cannot dynamically add scripts to a build of your App since the compile environment does not exist in a runtime build. You could write editor scripts that move scripts from some other location into your project in the editor, or alternately you could put all of your scripts in a Package. Then you can use Import Package and select any script you want to add.
Answer by Loius · Jun 19, 2014 at 08:14 PM
As mentioned, a built Unity game does not have a compiler. You won't be able to import scripts unless you have an interpreter and a scripting language that you include in the actual game itself. LUA was mentioned last time I saw this question.
Your answer
