- Home /
Problem is not reproducible or outdated
...FirstPersonController.m_WalkSpeed is inaccessible due to its protection level
I can't access my FirstPersonController variables despite making them public, here is the full error :
Assets/Script/script.cs(15,67): error CS0122: `UnityStandardAssets.Characters.FirstPerson.FirstPersonController.m_WalkSpeed' is inaccessible due to its protection level
In script.cs :
using UnityStandardAssets.Characters.FirstPerson;
...
GetComponent<FirstPersonController>().m_WalkSpeed = 0f;
and in FirstPersonController.cs :
[SerializeField] public float m_WalkSpeed;
I would try closing and reopening whatever thing you are using to do the compiling, which I assume is the editor.
http://s2.quickmeme.com/img/4a/4a102f0529cd0acddfa88a8dea431001d8e671f9def8ecaa6992bc455cee56f4.jpg
What do you use to compile? Is it the editor?
I never compile any scripts with the editor. I do everything to do with coding in Visual Studio and use the editor for modifying assets, game objects, et cetera.
Are you using any kind of source control? I have seen this occur with source control, when the file is not checked out. No idea why?
Have also seen it when the .cs file is set to Read Only on the drive.
What's a source control ? Also the file isn't set to read only
If you don't know what it is, then you are most likely not using it, so that is not causing the problem you are describing.
I'll be honest. I do not have any idea what is up. The code you posted should be working just fine. I can't see any reason that this variable would not be accessible.
I am sorry :(
@imdadddddd I set m_WalkSpeed to public and had no problem accessing it. I cannot reproduce the problem. It must be something with your setup.
Isn't there any way to find the source of this problem ? Can unity compiler give me more details ?
Follow this Question
Related Questions
2D Animation does not start 1 Answer
can I set a variable for a component to null 1 Answer
Change image alpha of a raw image component stored as a variable 1 Answer
How do I find the name and value for each variable of a script component, using Unity script? 2 Answers
Using static typing for a Component 1 Answer