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
0
Question by mattytheratty · Dec 07, 2012 at 09:33 AM · texturesmenuballoptions

How could I have a ball chooser menu?

I am making a ball rolling game, and I want to have different balls unlock as the character progresses. Some may be slightly quicker (or have different properties), and others may just look different.

How could I make a screen where the player could scroll though all of the balls, and they have a locked texture on them if they are locked, or be select able if not? When they are scrolling, a text box at the top of the screen should update to each ball, meaning that a ball is always selected. It would then display information about each ball, such as the name and speed.

I have all of the textures I need, but how could I implement a system to change between them in-game with their textures being visible (or locked where appropriate)?

Thanks, --Matt

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
0

Answer by konashadow · Dec 07, 2012 at 03:15 PM

If you make the texture of the ball a Global Variable, you can set the texture based on what ball they choose. You could make a global boolean variable for each ball to check whether it is unlocked or not. I'm not sure about how to make a scrolling menu, but you could allow the user to move the camera left or right. Then you can use this to see which one they hit:

 if(Input.GetMouseButtonDown(0))
     {
         ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         if(Physics.Raycast(ray, hit))
         {
             if(hit.transform.tag == "Ball")
             {
                 if(hit.transform.name == "NormalBall")
                 {
                     //change the texture here
                 }
             }
       }
 }

This will sense which ball they click. You can change the tag and the name, or take out the tag completely.

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 mattytheratty · Dec 07, 2012 at 04:29 PM 0
Share

Thanks, but I am a bit of a Unity idiot, so could you give some example code for how to change the texture?

Thanks, --$$anonymous$$att

avatar image Itinerant · Dec 07, 2012 at 04:59 PM 0
Share

Check this page out: it gives instructions on how to change the texture of a material. By looking into the reference docs for material, you could also learn how to make a different material for each ball, and then switch those.

https://docs.unity3d.com/Documentation/ScriptReference/$$anonymous$$aterial-mainTexture.html

avatar image konashadow · Dec 10, 2012 at 02:17 AM 0
Share

You can set a global texture variable by declaring it at the beginning of the menu's script like this :

static var ballTexture : Texture;

Then you can use a code similar to what i wrote above and in place of where I put the //change texture here, you can do ballTexture = someTexture;

Next, in the ball's script, you can create another texture variable (doesn't have to be a global one) called texture and set it equal to ballTexture like this - (assu$$anonymous$$g the menu's script is called menu)

menu(script name).ballTexture(global variable) = texture

Hope this helps!

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

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Quality-Settings Selections in scripting 1 Answer

How to make a Main Menu 3 Answers

One GameObjects Script Activating Another GameObjects Script 1 Answer

[Closed] MainMenu Script error 2 Answers

CoD 4 "weapon classes" 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