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

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

using Random = UnityEngine.Random;


  • Hi @MostafaYahia,

    it means that the script uses the Random class / namespace from Unity and not another one like System for example. If you remove this line, you will receive errors stating that there are multiple sources available for using Random (UnityEngine and System in this case).
  • 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.


Sign In or Register to comment.