Hello!
I just was extending one of our editor-scripts by automatically saving changes made on some ScriptableObjects done by the tool.
For that I made use of:
EditorUtility.SetDirty(modifiedScriptableObject);
AssetDatabase.SaveAssetIfDirty(modifiedScriptableObject);
This works totally fine and I can make builds in the local editor just fine.
When I check this into our vcs system, our build-server (jetbrains-teamcity) will pull the project, and runs our build-scripts with the same editor-version in batchmode.
Step one is:
- Opening the project in batchmode and execute a static function to change the build-target, scripting define symbols etc.
Step two is: - Opening the project again via commandline in batchmode to actually build the application. (necessary because of this mentioned in adressables docs)
Rinse and Repeat for every target-platform (windows/mac/…)
Now since we made use of the above mentioned function on AssetDatabase, the build fails in Step 1 for the first Platform (Windows - ReleaseBuild)
With the Compile-Time-Error:
error CS0117: ‘AssetDatabase’ does not contain a definition for ‘SaveAssetIfDirty’ (new); scripts have compiler errors.; exit code 1
Does anyone here has an Idea as of what could happen there? The Script is inside of an Editor-Only Assembly so this is not an issue of some missing #if UNITY_EDITOR (also tried wrapping it additionally), and the script shouldn’t even matter on that platform. Seems like an issue with the assembly being compiled falsely by the compiler:
How can this one method go missing, but anything else in the script (also uses AssetDatabase and EditorUtility Functions) is there? If I comment out the line using the function the build works fine (of course the autosave feature doesn’t work then).
We’re on Unity Version 2021.1.28f1 if that matters.