public override void OnInspectorGUI()
 {
     if (GUILayout.Button("Launch Python Script", GUILayout.Height(35)))
     {
         string path = Application.dataPath + "/Plugins/LeapMotion/Core/Scripts/Python_Scripts/test.py";
         PythonRunner.RunFile(path);
     }
 }
    void CamCapture()
    {
        // ScreenCapture.CaptureScreenshot(Application.dataPath + "/Screenshots/" + fileCount + ".png");
        // fileCount++;

        string path = Application.dataPath + "/Plugins/LeapMotion/Core/Scripts/Python_Scripts/test.py";

        PythonRunner.RunFile(path);
    }
Ejemplo n.º 3
0
        public void TestRunFile()
        {
            string validFileName      = Path.Combine(TestsPath, "testPythonFile.py");
            string fileWithErrorsName = Path.Combine(TestsPath, "testPythonFileWithError.py");
            string nonExistantFile    = Path.Combine(TestsPath, "doesNotExist.py");
            string notAPythonFile     = Path.Combine(TestsPath, "notAPythonFile.txt");

            // null file
            Assert.Throws <ArgumentNullException>(() =>
            {
                PythonRunner.RunFile(null);
            });

            // does not exist
            Assert.Throws <FileNotFoundException>(() =>
            {
                PythonRunner.RunFile(nonExistantFile);
            });

            // not a python file. Throws syntax error. File must not be empty
            Assert.Throws <PythonException>(() =>
            {
                PythonRunner.RunFile(notAPythonFile);
            });

            // Indentation error
            Assert.Throws <PythonException>(() =>
            {
                PythonRunner.RunFile(fileWithErrorsName);
            });

            // finally, a good, valid, file
            // Also testing scopeName parameter
            string scopeName = "__main__";

            UnityEngine.TestTools.LogAssert.Expect(LogType.Log, scopeName);
            PythonRunner.RunFile(validFileName, scopeName);
            // should create a game object named Alice
            var go = GameObject.Find("Alice");

            Assert.That(go, Is.Not.Null);
            GameObject.DestroyImmediate(go);
        }
    static void MergeSort()
    {
        string scriptPath = Path.Combine(Application.dataPath, "MergeSort.py");

        PythonRunner.RunFile(scriptPath);
    }
 static void RunEnsureNaming()
 {
     PythonRunner.RunFile($"{Application.dataPath}/_Scripts/renamer.py");
 }