Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

-executeMethod with Assembly Definition

Discussion in 'Scripting' started by MNNoxMortem, Dec 20, 2018.

  1. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    How do I use "-executeMethod ClassName.StaticMethodName" when using assembly definitions? Unity is unable to find the class when I use an .asmdef file.

    Example path "Assets/Plugins/Build/BuildTool.cs" and "Assets/Plugins/Build/Build.asmdef" with a "public class BuildTool" without a specific namespace and a method "public static void DoStuff(){}";
     
    Last edited: Dec 20, 2018
  2. androshchuk-vladyslav

    androshchuk-vladyslav

    Joined:
    Dec 13, 2015
    Posts:
    127
  3. lukaszunity

    lukaszunity

    Unity Technologies

    Joined:
    Jun 11, 2014
    Posts:
    461
    Please report a bug with a small repro and we will look into it.
     
    Bunny83 and karl_jones like this.
  4. androshchuk-vladyslav

    androshchuk-vladyslav

    Joined:
    Dec 13, 2015
    Posts:
    127
    Like here is nothing to place in repo. Or you need a reported bug in system?

    Unity.exe -quit -batchmode -executeMethod MyEditorScript.PerformBuild
    only works for class
    MyEditorScript
    in Editor default assembly. It can't be used with custom
    .asmdef
    file.
     
  5. lukaszunity

    lukaszunity

    Unity Technologies

    Joined:
    Jun 11, 2014
    Posts:
    461
    Yes, please report a bug so we can track and get all the details right. There could be multiple bugs in this area and we want to make sure we fix the one you are encountering :)
     
    Bunny83 likes this.
  6. hugeandy

    hugeandy

    Joined:
    Nov 2, 2016
    Posts:
    130
    Bump. I'm experiencing this in 2020.1.11f1

    The method I am trying to call with -executeMethod is a public static method inside a class which is in an assembly definition with only "Editor" ticked as a platform.

    I get:
    Aborting batchmode due to failure:
    executeMethod method 'METHODNAME' in class 'NAMESPACE.CLASS' could not be found.
     
  7. BlackclawsK

    BlackclawsK

    Joined:
    Jan 9, 2019
    Posts:
    100
    This appears to still be an issue unless I am doing something wrong @lukaszunity was this ever reported as a bug and fixed?

    EDIT: This was fixed. I was just running into a different issue where Unity continues the import on failing the script compile and then complains that it can't find the script
     
    Last edited: Aug 25, 2021
    MNNoxMortem likes this.
  8. QAMightandDelight

    QAMightandDelight

    Joined:
    Mar 17, 2021
    Posts:
    6
    @BlackclawsK Do you have further details on where this was fixed? Was it mentioned in release notes or did the problem just go away on your side?
     
  9. BlackclawsK

    BlackclawsK

    Joined:
    Jan 9, 2019
    Posts:
    100
    I never had the problem in the first place. My problem was of a different nature. The problem statement here was that you cannot call classes from asmdef files. Which _is_ possible now. You can still run into the error: "Class not found" if your scripts fail to compile in the first place.
     
    Bunny83 likes this.
  10. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    3,606
    It doesn't seem like they added a note to the release notes. I checked my release notes database and the only one found where "executeMethod" was mentioned was in the 2020.1.0 notes. Though on a different topic. Maybe the issue (with asmdef files) wasn't actually related to the "executeMethod" command line argument but may had its roots deeper in the system. So it's difficult to search for it in the release notes.

    (ps: I have a mysql table with all release notes, manually copied ^^. So I can actually do more sophisticated searches on them. Google and other search engines are not reliable enough. They tend to forget things if they age).