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;
i just imported the photon and i found this line of code
Any Explanation ?
using Random = UnityEngine.Random;
0
Best Answer
-
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).5
Answers
-
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).5 -
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 lineUnityEngine.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 ?0 -
ah @Christian_Simon beat me to it0
-
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
0