what is the meaning of this line of code in launcher script ?

Hello
i just imported the photon and i found this line of code
Any Explanation ?

using Random = UnityEngine.Random;

Best Answer

Answers

  • JohnTubeJohnTube mod
    edited January 23
    Hi @MostafaYahia,

    Thank you for choosing Photon!

    That line means from now on in the same scope of this using statement, most likely, document/file, whenever we use "Random" class we are referring to the Random class of Unity Engine (from the namespace UnityEngine). This is useful to avoid repeating the long line UnityEngine.Random every time. This was used in this case as there is another class with the same name in the .Net/Mono framework's default System namespace (System.Random). So to avoid conflict we explicitly tell the compiler which class we are going to use. It's like an alias or a shortcut.

    @jeanfabre maybe you should add this to the PUN Basics Tutorial as I believe this is where we got this from, right @MostafaYahia ?
  • ah @Christian_Simon beat me to it :)
  • Hi,

    I removed it, this was a bad copy paste from other code when I started developing this demo. Your explanations are valid, but it's just not being used in this particular context.

    Bye,

    Jean
Sign In or Register to comment.