Hi,
I’m trying to integrate scripting (http://csscript.net) into my application.
I’ve got it working inside the Editor, but it fails when building a standalone build.
Basically I’m loading this TestScript.cs and executing it:
using System.Collections;
public class TestScript
{
public static string Test()
{
return "Yeah !";
}
}
Opening it like described here http://www.mindthecube.com/blog/2009/11/reading-text-data-into-a-unity-game :
void Start(
{
try
{
string file = "TestScript.cs";
DebugConsole.Log(Application.dataPath + "/" + file);
System.IO.FileInfo theSourceFile = null;
System.IO.StreamReader reader = null;
theSourceFile = new System.IO.FileInfo (Application.dataPath + "/" + file);
if ( theSourceFile != null
theSourceFile.Exists )
reader = theSourceFile.OpenText();
if (reader == null)
{
DebugConsole.Log(file + " not found or not readable" , "error");
}
else
{
string myString = reader.ReadToEnd();
AsmHelper scriptAsm = new AsmHelper(CSScript.LoadCode( myString, null, false));
string result = (string) scriptAsm.Invoke("TestScript.Test");
DebugConsole.Log("Result = " + result , "warning");
}
}
catch (System.Exception e)
{
DebugConsole.Log("Exception = " + e.ToString() , "warning");
}
}
That works in the editor :
but fails in a standalone build (doesn’t matter if MAC or PC).
My problem is, I’m not quite sure, if that error is Unity related or belongs to the scripting host.
I clearly see the line, but I’m sure , its in the right location (/Content Folder on OSX , /Data on Win), because otherwise my own check, if file exists, pops up.
So, if anyone has an idea, what that error message is about, I really would appreciate some hints. I’m on Unity Pro.
Hope that makes sense,
thanks in advance …
oxl