Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by CalledToGaming · May 03, 2010 at 12:24 AM · guimouseslider

'MouseLook.sensitivityX' is inaccessible due to its protection level.

I'm getting this error when trying to create a slider GUI to adjust mouse sensitivity while in game? I know the script is correct for accessing the MouseLook Script and variable, but I'm still getting the error:

'MouseLook.sensitivityX' is inaccessible due to its protection level.

any Ideas?

//Look Sensitivity x axis
    GUI.Label(Rect(25,125,100,150),"X Axis");
    MouseLook.sensitivityX = GUI.HorizontalSlider(Rect(25,150,100,25),MouseLook.sensitivityX, 2.0,15.0);

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by Molix · May 03, 2010 at 02:06 AM

If it is talking about protection level, then presumably the variable is not "public", e.g.

public static float sensitivityX;

public static var sensitivityX : float;

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image qJake · May 03, 2010 at 02:07 AM 0
Share

It's public in the default version of the script. $$anonymous$$ouseLook is a standard asset, and its definition is "public float sensitivityX;", so unless this person modified their script, this isn't the problem.

avatar image CalledToGaming · May 03, 2010 at 02:29 AM 0
Share

Thank you, that was the problem. I don't know why I didn't think of it myself. I hadn't set the var to public, and it's not set that way by default in my version, and I'm using the standard assets version too. so, I dunno what's up, but it works now, thanks.

avatar image CalledToGaming · May 03, 2010 at 02:32 AM 0
Share

Correction. When I moved the Var to a static, I accidentally erased the public part. That was my problem. thanks for the help guys.

avatar image
0

Answer by qJake · May 03, 2010 at 12:45 AM

You can't just call the sensitivityX property of your script, that's not how the scripting works.

You need to get a reference to the MouseLook script before you can change it. Like this:

// C#
MouseLook ml = GetComponent(typeof(MouseLook)) as MouseLook;
ml.sensitivityX = 1; // or whatever
Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image CalledToGaming · May 03, 2010 at 12:51 AM 0
Share

Well, I've done it with other variables in scripts and it works just fine, this is the first time I've had this error.

avatar image qJake · May 03, 2010 at 01:17 AM 0
Share

That's because those other scripts have their variables set to static. I don't mean to sound harsh, but if you don't know program$$anonymous$$g very well, Unity isn't the best place to start, as there are a lot of quirks that aren't present in regular program$$anonymous$$g.

avatar image CalledToGaming · May 03, 2010 at 01:20 AM 0
Share

The sensitivytX variable is set to static as well...

avatar image qJake · May 03, 2010 at 02:00 AM 0
Share

It isn't static in my version of the script (unmodified): http://img98.imageshack.us/img98/7418/nostatic.png - Did you modify it?

avatar image lil_billy · Oct 29, 2012 at 02:41 AM 1
Share

um thats not true

a variable does NOT have to be static in order to be accessible by another script thats why we have public and private variables

GetComponent(somescript).somevar=something;

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

GUI Sliders in the same script. Question (Js.) 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Need help with my script 0 Answers

I need Help With a Speed up script 1 Answer

GUI.HorizontalSlider not working 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges