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 allesisda · Jan 14, 2013 at 11:57 PM · guibuttontimegui.buttonsame

multiple GUI.Buttons at the same time

hi there, i wanted to do a fast GUI.Button menu and use it as input for android devices...

so i have RepeatButtons w,a,s,d and public static booleans: Wispressed, Aispressed and so on

if (GUI.RepeatButton(new Rect(x1-50, y1, 50, 50), "A")) {a=true;} else a=false;

my problem is, that i can't press many buttons at the same time. if i am pressing "D" do walk forward and than press "W" to jump while walking (its a 2d platformer) the jump is not beeing done...

some ideas? thanks for help!

Comment
Add comment · Show 2
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 DaveA · Jan 15, 2013 at 12:55 AM 0
Share

Have you considered using Input.touches ins$$anonymous$$d?

avatar image allesisda · Jan 15, 2013 at 08:18 PM 0
Share

i allready had a look on Input.touch but i don't really understood it :/

what shoud be the code for a Gui button-like thing, that i can touch while touching others of the same kind?

i thought buttons would be a nice way, because i can test the funktionality on the pc too...

1 Reply

· Add your reply
  • Sort: 
avatar image
3

Answer by Shaander1 · Jan 15, 2013 at 08:37 PM

Here's what I could whip up, turn your current GUI Buttons into GUITextures then do the following in OnGUI:

     // Set these to the proper rect you have defined in your code.
     Rect wRect = new Rect( 0, 0, 50, 50 );
     Rect aRect = new Rect( 0, 0, 50, 50 );
     Rect sRect = new Rect( 0, 0, 50, 50 );
     Rect dRect = new Rect( 0, 0, 50, 50 );
     
     bool wPress = false;
     bool aPress = false;
     bool sPress = false;
     bool dPress = false;
     foreach ( Touch t in Input.touches )
     {
         if ( wRect.Contains( t.position ) )
             wPress = true;
         else
             wPress = false;
         
         if ( aRect.Contains( t.position ) )
             aPress = true;
         else
             aPress = false;
         
         if ( sRect.Contains( t.position ) )
             sPress = true;
         else
             sPress = false;
         
         if ( dRect.Contains( t.position ) )
             dPress = true;
         else
             dPress = false;
     }
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 DaveA · Jan 15, 2013 at 08:37 PM 0
Share

What he said

avatar image anuraganand.hazaribag · Apr 23, 2016 at 04:50 AM 0
Share

Hey there is no compilation error and i have added this code in OnGUI but gui buttons are not shown.

avatar image birns92 anuraganand.hazaribag · Apr 23, 2016 at 05:44 AM 0
Share

this article might help

avatar image tanoshimi anuraganand.hazaribag · Apr 23, 2016 at 06:12 AM 0
Share

Doing this in 2016, you should really use the UI... https://unity3d.com/learn/tutorials/modules/beginner/ui/ui-button?playlist=17111

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

16 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

Related Questions

GUI Button appears when Paused 1 Answer

(Unity 4.6) Button animations 1 Answer

Make more buttons appear, on button click. 1 Answer

GUI Button Not Displaying? 1 Answer

Toggling multiple button states 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