Add this line to your function Debug.Log(“Writing to file”); and then check the Editor.log. If your debug message appears, the problems should be in your WriteAllText call.
What I understand is that I can execute a CS file method from command line with Unity using this line:
/Applications/Unity/Unity.app/Contents/MacOS/Unity -batchmode -quit -projectProject ProjectPath -executeMethod FileName.StaticMethodName
That line will launch Unity, that will start the project and execute the method of that file (FileName.cs).
Now the file only contains this, without using statements, only this:
static void MyMethod () {
Debug.Log (“Esto es una prueba”);
}
If I open the Editor.log (/Users/Jordi/Library/Logs/Unity/Editor.log), I see this text:
Esto es una prueba UnityEngine.Debug:Internal_Log(Int32, String, Object) UnityEngine.Debug:Log(Object) Test:MyMethod() (at Assets/Editor/Test.cs:7) (Filename: Assets/Editor/Test.cs Line: 7)
I got it!
Everything was OK but I had some errors in my script.
I wrote using UnityEditor; and I have also declared the static method inside a class, something like this:
using UnityEngine;
using UnityEditor;
public class MyScriptName {
public static void MyMethod () {
Debug.Log (“Here you put your code”);
}
}
And you have to call it from command line like this: ./Applications/Unity/Unity.app/Contents/MacOS/Unity -batchmode -quit -projectPath ${PROJECT_PATH} -executeMethod MyScripName.MyMethod