0
\$\begingroup\$

I wrote an editor script to de-parent GameObjects via Transform.SetParent(null) if all of their parents had default scale and no components.

This executed in IProcessSceneWithReport.OnProcessScene().

I had one particular GameObject in the scene with such a parent, and made a UI text that would show the name of that parent, or "None" if it was null (showing that my build script worked).

All of the above worked nicely, and when I played the scene or built the project, my UI text showed "None".

When I deleted the script and played the scene, it showed the name of the parent object.

However, when I built again with the script now deleted, the executable once again showed "None", as if the script was still there.

What could be causing the build to act as if the now-deleted script was still there?

I'm using Unity 2022.3.35f1.

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

Some possible causes:

  1. You have multiple similar scenes, and the scene that is showing in the build is a different scene than in the Editor (check the scenes in the Build Settings).
  2. You saved the new build to a different folder than the previous build, and are opening the old build from the previous folder.

To help troubleshoot this and future issues, you should put a version number somewhere in the first scene that loads when the game starts; you can use Application.version to get the version number from the project settings, and then display it in a Text / TMP_Text component. If you don't see the version number, or it's the wrong version, then you know that you're looking at the wrong build.

\$\endgroup\$
2
  • \$\begingroup\$ So it was a test project with only one scene. and when I re-built it, I had deleted the contents of the previous built (the only build) before using the same folder. My next best guess is that any build scripts generated/cached by unity were re-used since the folder name was the same. It sounds like more testing is needed. \$\endgroup\$
    – Wiley Rush
    Commented Aug 11 at 9:03
  • \$\begingroup\$ Could be the old script's compiled form was still saved in the Library folder, or its in-memory version was still linked to the PostProcessScene event because the domain hadn't been reloaded. (Do you have any of the preferences for accelerating the switch to play mode enabled? These can turn off clean-up steps and allow old state to persist unless you manually clear it) \$\endgroup\$
    – DMGregory
    Commented Aug 11 at 11:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .