ScriptExecutionOrder has too many selections to find the desired Script.
I tried to change the execution order of a particular Script in ScriptExecutionOrder.
However, as you can see, when there are many scripts in a particular asset, etc., it is very difficult to find the desired script.
I kept pressing the bottom black inverted triangle for over a minute and could not get to the desired script.
It is expected that the more assets there are in the future, the more scripts there will be. Also, assets are in use and cannot be erased.
Is there a better way to quickly select the desired script?
You can start typing in the selection you want and it will navigate to it. This has always been true of windows native menus like this. There’s also an undocumented attribute, [DefaultExecutionOrder]
, that let’s you do this via code.
The important bit is: why?
The SEO is a crudge that you should avoid using at all costs!
Use only when you run into an issue where the alternative solution would require either modifying someone else’s code (with possible or actual side-effects that are hard to assess/solve, or with that code simply not being modifiable) or as a quick-fix that has less repercussions compared to making code or architectural changes (typically near the end of the dev cycle).
In almost every case there is an easier and better solution. For instance, never rely on Awake being executed in a given order. Only use Awake to assign references ie via GetComponent or Find and never call into other components. Defer the latter to either OnEnable or Start.
Example issue: accessing a Singleton.Instance in Awake where the Singleton instance is assigned in Awake which may happen before or after another component’s Awake.
Possible solutions:
- make the Singleton.Instance never return null - this can be done with a self-instancing Singleton which is only created (or found and assigned, or loaded and instantiated) when first accessed
- defer calling the Singleton.Instance to OnEnable/Start
- if the goal is to assign this to Singleton.Instance for access by other scripts, have the Singleton itself find that reference (pull/find rather than push/assign)
- architectural changes …
Thank you for your reply.
I just learned that I can focus on the initial letter position by typing the alphabet key.
Thanks for the very useful information.
However, I ran into another new problem along the way
I typed in the desired script acronym, but the Windows warning tone sounded and the focus failed.
I checked and it shows scripts up to A, B, C, and D, but not E and beyond.
I am trying to address this with [DefaultExecutionOrder]
for the time being, but does anyone know anything about this issue?
Is there even a maximum number of scripts that can be displayed in the candidates?
Thanks for the advice.
You should not refer to other components in Awake, I agree with this.
But deferring to OnEnable did not solve the problem.
Please see this order of execution.
I used to think that OnEnable was executed after Awake of all objects.
But in fact, the order is Awake → OnEnable → Awake → OnEnable…
This specification means that OnEnable has the same problems as Awake.
However, in my project I use OnEnable so often that it is difficult not to reference components in OnEnable (For example, I monitor the flags of objects and if they do not meet the appearance conditions, I immediately execute SetActive (false) with OnEnable.)
Therefore, it is now necessary to load the script that manages the flags of the game first
Start() still exists.
You could also modify the .meta file by hand.