Script Order in GameObject Matters ... Why?

I haven't encountered this before in Unity so I was curious why this is happening: Why does script order in a GameObject matter when Unity is using Photon?

Try this with the demo-realtime-unity: http://doc.exitgames.com/v3/demos/realtimedemolive
Found in: http://www.exitgames.com/Download/Photo ... DK-RC1.zip

- Remove Demo and Input script from PhotonScripts
- Re-add Demo and Input to Photon Scripts (this moves the script below the Game script)
- Fill in the Game Instance and Player Model variables in Demo and Input
- Try to run the program

It won't work anymore. If you do a stack trace the code blows up with an exception error when it tries to run:

this.Peer = new LitePeer(this, this.UsedProtocol);

in the Game's Connect method.

Now:
- Remove the Game script from PhotonScripts
- Re-add the Game script (Demo and Input is now on-top)

It works again ...


is this voodoo or am I missing something painfully obvious?

Comments

  • have never tried the demo, but normally if 'order' matters then the code is the problem. For example accessing another object in Awake within a MonoBehavior is a big no go, accessing other objects must not happen before Start.

    The problem is the line you cite there should never be a problem as it is not related to initialization of unity and itself.
  • That makes sense.

    I guess that the demo wasn't designed to be very robust and there's a check missing in either the Demo GUI and Input script or the Game script.
Sign In or Register to comment.