Hi all
I am working on a game in which the player write his own C# script and apply them to an objects.
And in one scene the player write his code and game saves it as X.cs, if I run the game in the editor it saves the scripts in assets and if I run the game in a PC build it doesn’t work probably because the script isn’t included in the assests folder.
short story:
When I run the game in the editor the game works perfectly OK but on the build it doesn’t run the script.
here is the script that add the player script in to the object:
public bool once = false;
public string script;
public InputField loadScript;
// Use this for initialization
void Start() {
}
// Update is called once per frame
void Update () {
script = loadScript.text;
if (Input.GetKeyDown(KeyCode.LeftControl) == true) {
if (once == false) {
System.Type MyScriptType = System.Type.GetType(script + ",Assembly-CSharp");
gameObject.AddComponent(MyScriptType);
once = true;
}
}
}
}
is it even possible to run an external C# script like this if not how can I replace it?
I have read about lua scripting(moonsharp, lua interface, Nlua) but i don’t know how to work with it.
thanks for the help.