- Home /
multiple c# properties declaration
Hi, currently I have 14 properties nicely loaded up. I want something like:
public static Vector2 i1,i2,i3 {get; private set;}
This way I can maintain code easily. Looks like unity/c# does not let me do this. What am I missing?
Answer by Roland1234 · Dec 02, 2013 at 05:54 PM
You cannot declare multiple properties in C# in one line like you're attempting to in your code. You will have to do something like this:
public static Vector2 i1 { get; private set; }
public static Vector2 i2 { get; private set; }
...
Also, be aware that although you can use static fields/properties in code just fine, they will not show up anywhere in the Editor - you can use the singleton pattern with serialized private backing fields, but that's a separate issue.
static fields/properties will not show up on editor? didn't know that, thats a bit weird!!
It is somewhat at first, until you realize that the Editor is inspecting serialized object instances, so it makes sense that static members wouldn't show up. But proper implementation of the singleton pattern gives you the best of both worlds (static members editable inside Unity), so its not so bad.