Search code examples
c#unity-game-engineorder-of-execution

Start a script before all in Unity (Script Execution Order doen't work)


I handle all player's data in one script called "binaryStorage". When the game starts, in the first scene, I have put the player's total points, the problem is that when the script that handles all this scene try to get the player's total points, it gets the 0 value (because it call the method "getPlayerPoints" inside the script 'binaryStorage' before that script has been initialized).

To fix this I tried to edit the script execution order of 'binaryStorage', editing the default time by '100' to '90' but nothing changes, the script that handles the scene ever starts before this.

Any ideas? Am I doing something wrong?


Solution

  • Script Execution default time is 0

    So setting a script time to -1 will execute it before the default time.

    Image illustrates the execution order of -1, default, 1 and 100 enter image description here