Пример #1
0
        void onGUI()
        {
            if (GUILayout.Button("EvalMath") == true)
            {
                // Eval some C# math code
                Debug.Log(evaluator.Eval("return 6 * 3 + 20;"));
            }

            if (GUILayout.Button("EvalLoop") == true)
            {
                // Eval for loop code
                evaluator.Eval("for(int i = 0; i < 5; i++) Debug.Log(\"Hello World \" + i);");
            }

            if (GUILayout.Button("EvalVar") == true)
            {
                evaluator.BindVar("floatValue", 23.5f);

                // Eval var code
                evaluator.Eval("Debug.Log(floatValue + 4f);");
            }

            if (GUILayout.Button("EvalRefVar") == true)
            {
                Variable <float> shared = evaluator.BindVar <float>("floatValue", 12.3f);

                // Eval var reference code
                evaluator.Eval("floatValue *= 2;");

                Debug.Log(shared);
            }

            if (GUILayout.Button("EvalDelegate") == true)
            {
                evaluator.BindDelegate("callback", () =>
                {
                    Debug.Log("Hello from callback");
                });

                // Eval delegate code
                evaluator.Eval("callback();");
            }
        }