Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Elias Ayende · Jun 03, 2010 at 01:22 AM · nullreferenceexceptionjoystickpenelope

Error when doing Penelope Tutorial. Need Help

I just finished the joystick script and everything is fine but when I attach the Joystick script to the right joystick I get a "NullReferenceException" as an error. The script is perfect when it's on the left pad but when I add it to the right pad I get that error.

When I double click on the error it highlights this line of code.

gui.pixelInset = defaultRect;

I just needs someone to explain what that error means.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Cap · Jun 03, 2010 at 11:52 AM

Could there be a second script or a GUI component you need to attach as well? Check both joysticks in the inspector and make sure they have all the same components.

Comment
Add comment · Show 4 · 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 Elias Ayende · Jun 04, 2010 at 05:22 AM 0
Share

So far I've made the Joystick Script and that's all and I've had it attached to the left Joystick the whole time. Once I finish writing the Joystick Script, and everything is fine at that point, I go ahead and attach the script to the Right Joystick and then I get the error. When I test run it the Joystick still moves as it was but the Right doesn't move at all even though there made the same just with different names.

avatar image Cap · Jun 04, 2010 at 11:19 AM 0
Share

Well, from the error it looks like the script is trying to reference something and can't find it. defaultRect must be a custom variable, so look for it somewhere in your first joystick and its children (if any) and attach the same component/object to the second one if you find it. There's also a chance the second joystick needs something like a GUILayer component or one of the other GUI components. In any case, something which exists in/for the first joystick is missing for the second.

avatar image Elias Ayende · Jun 05, 2010 at 01:12 AM 1
Share

This answer was very helpful but it turns out that it was working but it only moves one texture for some reason ins$$anonymous$$d of both. Basically the joystick texture was in different spots but the center of the rectangle (defaultRect) we were referencing to was in the same spot for both the joysticks. We can see in the inspector though that were moving both the joysticks but only one Joystick has it's texture move. After doing some tests I feel as If unity randomly picks which texture moves whenever I close and re-open Unity.

avatar image Cap · Jun 05, 2010 at 02:49 AM 0
Share

Ah, well then just duplicate the GUI whateveritis and alter the script for the second joystick so it uses the new one. Adding a new variable outside your functions in that script file and setting its type to whichever GUI component you're using will let you drag the first texture to the first joystick's inspector and the second texture to the second.

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

No one has followed this question yet.

Related Questions

Penelope joystick in C# 1 Answer

joystick boundary is rectangle not cycle 3 Answers

NullReferenceException: Object reference not set to an instance of an object 3 Answers

NullReferenceException when using Single Joystick prefab 1 Answer

cycle joystick navigation similar to penelope. 0 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