Order execution of the same script puzzle?

Hello there!

So, it looks like I have one script which is attached to different objects.

How can I set order execution of this script? What a puzzler!

I tried to use mono manager but of course, it only helps with order of different scripts.

You can’t. Unity has internal lists which are used when you add or remove objects at runtime those lists will change. You can’t rely on a certain execution order.

The easiest way is to use your own function. For example:

// Follow.cs

public void ExecuteStuff()
{
    // ...
}


// FollowManager.cs

public Follow[] followScripts;

void Update()
{
    foreach(var script in followScripts)
        script.ExecuteStuff();

}

You need one FollowManager script and add a reference to the followScripts array in the inspector in the order you like.