#My private Serialize field variable gets me anerror

1 messages · Page 1 of 1 (latest)

glossy igloo
#

In my code, I have the line: private [SerializeField] float spd;

It gave me this error: CS1031: type expected at line 11, character 13. The [ is screwing it up, but I don't know why.

How would I fix this to have a private variable that can be changed in the inspector?

Edit: Thank you @grand nymph , your advice solved my issue.

grand nymph
#

So [SerializeField] private float spd;

#

or you can get rid of the private keyword completely, it will have the same effect
[SerializeField] float spd;

brittle glen
granite onyx
#

can only be accessed via the script it was written in