Search Unity

Question command line argument -executeMethod

Discussion in 'Scripting' started by RoughSpaghetti3211, Apr 4, 2022.

  1. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,709
    Quick question I was hoping someone can help me with this. I want to open Unity from the command prompt using the -executeMethod and executing a static method inside a custom package in my project, Is this possible?

    C:\"Program Files"\Unity\Hub\Editor\2020.3.30f1\Editor\Unity.exe -projectPath <ProjectPath> -executeMethod <MyMethodFromMyCustomPackage>

    works fine when my method is in asset/scripts folder

    Thanks in advance
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,752
    I would think it would... why don't you tell us when you find out!! :)

    I'm guessing that it will open Unity and compile everything, import everything, etc, then look at that string in whatever it considers the "list of all available assemblies" and go looking to launch that method.

    It would hinge upon whether code in packages gets put into assemblies that Unity might ransack for that executeMethod argument resolution.
     
  3. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,709
    Sorry I should have added I that I did test it and it could not find the method. This was more of a sanity question because this should work, right ?
     
  4. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,709
    The script is in the editor assembled so I’m really confused why it not finding it
     
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,752
    And I assume that's where the not-in-a-package-contained test method is, the one that works?

    Try this: from the not-in-a-package method that you CAN call, call the package-located method that doesn't seem to work directly.

    Might be interesting... I'm ready with my fire extinguisher.
     
  6. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,709
    Haha, ok so it started working. I made and editor folder in the package and put my script in there. Thanks for talking it through with me.
     
    Kurt-Dekker likes this.