• 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 Malik Ehtasham · Feb 25, 2013 at 07:50 PM · inputgui-buttoninput.getbutton

Getting contining input from GUI button when i press it

Hy .I am new in unity.I have small problem.I don't know wheather i should canvay it as i want or not.ok let me try.i have script which take user input just like this..

 var f_ver : float = Input.GetAxis("Vertical");
 var f_hor : float = Input.GetAxis("Horizontal");

this work fine in my logic but i want the same result with my GUI button.I want when i press A GUI button and continue to pressing it will giving me input as i get input when i press uparrow key from key bord.but actually its give me input only one time just when i clik it...So how can i do this...Sorry for my poor english..any help idea

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
0

Answer by raveren · Feb 25, 2013 at 08:38 PM

http://docs.unity3d.com/Documentation/ScriptReference/GUI.RepeatButton.html

Comment
Add comment · 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
0

Answer by Jeremy Hindle · Feb 25, 2013 at 08:36 PM

The thing you are looking for is a RepeatButton.

Here is the page on the Docs: http://docs.unity3d.com/Documentation/ScriptReference/GUILayout.RepeatButton.html

Examples for C#:

         if (GUILayout.RepeatButton("repeat button"))
         {
             doFunction();
         }



         if (GUI.RepeatButton(new Rect(0,0,30,10),"Repeat Button"))
         {
             doFunction();
         }
Comment
Add comment · Show 2 · 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 Malik Ehtasham · Feb 26, 2013 at 11:52 AM 0
Share

thanks Jeremy Hindle and Ravern ...Repeating button has solved my problem..thanks

avatar image Jeremy Hindle · Feb 26, 2013 at 12:10 PM 0
Share

mark as answered please.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

A node in a childnode? 1 Answer

Unit button and axis mapping issue 0 Answers

How to create an Alert Box in 4.6 UI? 3 Answers

GUI for Keyboard controls 0 Answers

Exact meaning of Input.GetButtonDown() 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges