- Home /
Requires a non-static variable
I'm coding some networking stuff, but that's irrelevant to the question. So int mv can't be a public int because it requires a non-static variable, but I need to use mv in void OnPhotonPlayerConnected. So how do I use it in that and keep it a non-static variable for the rest of the code?
Can someone please help I need this done, so I can reach my deadline. -Sorry if I come off as pushy.
Can someone one help? I've been stuck on this for a day now.
I'm unclear as to what $$anonymous$$V is?
So int mv can't be a public int but I need to use mv in void OnPhotonPlayerConnected.
Why it needs to be static? Simply put it public? ... Read this: http://answers.unity3d.com/questions/147920/using-non-static-variable-in-static-function.html
mv is how many players have connect to the server while it's been up, I'm using it to give players unique ID's. It doesn't matter anyways someone else solved the problem. Also I was putting it as public.
Answer by Kiwasi · Dec 06, 2014 at 12:33 AM
Access modifiers (public, internal, protected and private) have no relationship with static. Any of these combinations are valid. (C#)
public float myFloat;
internal float myFloat;
protected float myFloat;
private float myFloat;
public static float myFloat;
internal static float myFloat;
protected static float myFloat;
private static float myFloat;
Your question is poorly worded, so I can't tell which one you are after.
public static float was the only one that seemed to work. Thanks!
Your answer
