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 Shannon847 · Dec 15, 2020 at 12:13 AM · movementscript.menucolor change

Select-color menu that loops through colors as button is pressed

Hi, I am currently trying to make a menu that loops through the colors available for the main character with the use of 2 arrow keys. Does anyone know how I can do this efficiently? [1]: /storage/temp/172562-shop.jpg

shop.jpg (41.3 kB)
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
Best Answer

Answer by Pokedlg3 · Dec 15, 2020 at 03:51 AM

I don't understand what you want to do? could you be more specific?

do you want to change color when he clicks a key?

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 Shannon847 · Dec 16, 2020 at 08:23 AM 0
Share

Yes, when the button is pressed it should go to the next color. I currently have a menu where you click on a colored button and the rocket material then becomes that color but I would like to do it with these arrows instead if possible.

avatar image Pokedlg3 Shannon847 · Dec 19, 2020 at 05:45 AM 0
Share

Put this script on your rocket:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;

 public class ColorTest : $$anonymous$$onoBehaviour
 {
 [SerializeField]private Color blue;
 [SerializeField]private Color green;
 [SerializeField]private Color red;
 [SerializeField]private Color yellow;
 [SerializeField]private Color gray;
 [SerializeField]private Color black;
 [SerializeField]int lastColor = 0;
 [SerializeField]private $$anonymous$$aterial mat;

 void Start()
 {
     green = Color.green;
     red = Color.red;
     yellow = Color.yellow;
     blue = Color.blue;
     black = Color.black;
    gray = Color.gray;
    mat = gameObject.GetComponent<$$anonymous$$eshRenderer>().material;
 }

 void Update()
 {
     
     if(Input.GetKeyDown(KeyCode.RightArrow))
     {
         lastColor++;
     }

     if(Input.GetKeyDown(KeyCode.LeftArrow))
     {
         lastColor--;
     }

     if(lastColor == 0)
     {
         mat.color = blue;
     }
     if(lastColor == 1)
     {
         mat.color = red;
     }
     if(lastColor == 2)
     {
         mat.color = yellow;
     }
     if(lastColor == 3)
     {
        mat.color = green; 
     }
     if(lastColor == 4)
     {
         mat.color = black;
     }
     if(lastColor == 5)
     {
         mat.color = gray;  
     }

     if(lastColor < 0)
     {
         lastColor = 5;
     }

     if(lastColor > 5)
     {
         lastColor = 0;
     }
 }
 }

avatar image Shannon847 Pokedlg3 · Dec 28, 2020 at 12:19 PM 0
Share

Thank you so much! It works perfectly.

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

237 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Aligning animation with movement. 0 Answers

Slime script? 1 Answer

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

Simple 2D Enemy AI 3 Answers

Integration tests fail on 'Run All' 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