- Home /
Passing parameter with -executeMethod
Is is possible to pass one or more parameters to an Unity script when using -executeMethod from a build script?
I'd like to specify the BuildPipeline parameters from an external script.
Answer by jashan · Sep 09, 2010 at 09:44 AM
AFAIK, it is not possible to directly pass parameters with -executeMethod. The only type of parameter you could technically pass would be strings, anyways.
So, what I'm usually doing is provide one method for each set of options that I really need, and call the different methods as needed.
However, you probably could use Environment.GetCommandLineArgs to get all arguments from the command line and then do your own command line arguments parsing to be a bit more flexible. It still requires some custom string checking and parsing and converting to your actual parameters (likely with some switch-case-constructs), but it would certainly get you a bit more flexibility.
Answer by kork · Feb 10, 2016 at 07:49 AM
That link from epixcode.com is dead. Here is another article, which describes how to do it: https://effectiveunity.com/articles/making-most-of-unitys-command-line.html . The relevant section is somewhere in the middle of the article.
TL;DR:
var args = System.Environment.GetCommandLineArgs();
Hi, do you know of a similar method that would work for andorid and ios apps ?
Seems like the command line has no built-in switch for that. However you can call "BuildPipeline.BuildPlayer" in the function you call with the -execute$$anonymous$$ethod switch. That way you can build players for multiple platforms in one go as well. See https://docs.unity3d.com/ScriptReference/BuildPipeline.BuildPlayer.html.
Answer by tolache · May 22, 2021 at 12:29 PM
jj_unity328's answer here helped me: https://forum.unity.com/threads/pass-custom-parameters-to-standalone-on-launch.429144/
Your answer
Follow this Question
Related Questions
Get Console or Debug.Log output from Unity command line batch mode and custom build process 0 Answers
Command line flag to build WebGL 3 Answers
xr plugin managment arkit required script 0 Answers
Automate iPhone build 1 Answer
How Do I Procedurally Change the Icon, Splash Screen, and Version #? 1 Answer