コード例 #1
0
    public void Test_LoadScript()
    {
        // Try loading a good Lua Code
        bool result = functions.LoadScript(testCode1, "testCode1");

        Assert.AreEqual(true, result);
    }
コード例 #2
0
    public void CompareLUAvsCSharp()
    {
        bool resultCSharp = csharpFunctions.LoadScript(ReplaceQuotes(testCSharp), "FurnitureFunctions");
        bool resultLua    = luaFunctions.LoadScript(ReplaceQuotes(testLUA), "PowerGen");

        Assert.IsTrue(resultCSharp);
        Assert.IsTrue(resultLua);

        int iterations = 1000;

        List <string> cache = new List <string>(iterations * 2);

        Stopwatch sw1 = new Stopwatch();

        sw1.Start();
        for (int i = 0; i < iterations; i++)
        {
            cache.Add(csharpFunctions.Call <string>("PowerCellPress_StatusInfo", new Furniture()));
        }

        sw1.Stop();

        Stopwatch sw2 = new Stopwatch();

        sw2.Start();
        for (int i = 0; i < iterations; i++)
        {
            cache.Add(luaFunctions.Call <string>("PowerGenerator_FuelInfo", new Furniture()));
        }

        sw2.Stop();

        UnityDebugger.Debugger.Log(string.Format("Iterations: {0}", cache.Count / 2));
        UnityDebugger.Debugger.Log(string.Format("CSharp calls: {0} ms", sw1.ElapsedMilliseconds));
        UnityDebugger.Debugger.Log(string.Format("LUA calls: {0} ms", sw2.ElapsedMilliseconds));
    }
コード例 #3
0
ファイル: Functions.cs プロジェクト: smrkdev/ProjectPorcupine
    public bool LoadScript(string text, string scriptName, Type type)
    {
        bool result = false;

        if (type == Type.Lua)
        {
            LuaFunctions luaFunctions = new LuaFunctions();

            if (luaFunctions.LoadScript(text, scriptName))
            {
                FunctionsSets.Add(luaFunctions);
            }
        }
        else
        {
            CSharpFunctions netFunctions = new CSharpFunctions();
            if (netFunctions.LoadScript(text, scriptName))
            {
                FunctionsSets.Add(netFunctions);
            }
        }

        return(result);
    }