Home unity3d Unity: Start function sequence

Unity: Start function sequence

Author

Date

Category

To explain the essence of the question I made such a mini experiment.
I have 2 scripts – FirstScript.cs, SecondScript.cs

This is the first script

Public Class FirstScript: Monobehaviour
{
  Public int TestNumber = 0;
  Void Start ()
  {
    TestNumber = 1;
    Debug.log (testnumber.tostring () + "- by first script");
  }
}

And this is the second

Public Class Secondscript: monobehaviour
{
  Public FirstScript FirsTscript;
  Void Start ()
  {
    firstScript.testNumber = 2;
    Debug.log (firstScript.testNumber.tostring () + "- by Second Script");
  }
}

As you can see, I tried through the second script in the start to change the value of the first.
And in Console, I got it –

You see that at the end, the start of that script is running in which the variable is located.
Now my question: somehow you can change this sequence?


Answer 1, Authority 100%

The execution order of the scripts can be set in the Edit menu – Project Settings – Script Execution Order . Scripts will be performed from top to bottom. Not specified explicit scripts will be performed in the default .

Documentation

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions