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 COLLAnitySV · May 11, 2012 at 01:41 PM · androidguibuttontouchhold

Holding GUI Button Touch to Rotate Object

How to make an object rotates if you hold the GUI Button ? For instance : Turn Left Button, if you pressing (hold) turn left button, the object will rotates to the left till you lift your hand (TouchPhase.Ended).

Here's my script

 if(GUILayout.Button(someTextures[10])){
     if(Input.touches.Length > 0 && Input.touches[0].phase == TouchPhase.Began){
         rxz = -1 * 10;
         rxz *= Time.deltaTime;
     }else if (Input.touches.Length > 0 && Input.touches[0].phase == TouchPhase.Ended) rxz = 0;
     //cnt.isPressing[1] = true;
 }
 rxz is float = 0. at function update() prnt.transform.Rotate(0,rxz,0);

I also have a problem in launching the object for the first time. For Instance : I hold the GUI Button, it was directly become 1.50 (it should be clamping from 0 to 1.50) i don't know how to say.here's my another script

     if(isPressing[0]){
         if(Input.touches.Length >0){
             if(Input.touches[0].phase == TouchPhase.Began){
                 start = Time.timeSinceLevelLoad;
                 gui.ShowMe(true);
             }else if(Input.touches[0].phase == TouchPhase.Ended){
              end = Time.timeSinceLevelLoad;
              gui.ShowMe(false);
              hint.ShowHint(power.ToString("f2"),1.5, false);
              StopMe();
              force = power*speed;  // here you compare the 2 values I had to multiply by 20 to get it up (that's what she says) but you might have to alter this eqution to get what you want  
               if(throwingSFX ){
                       audio.Stop();
                       audio.clip = throwingSFX[Random.Range(0,throwingSFX.length)];
                       audio.Play();
               }
             }
         }
     }

from another GUI Script if(GUILayout.Button(someTextures[8]))cnt.isPressing[0] = true;

Comment
Add comment · Show 1
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 maroonrs2 · May 11, 2012 at 02:23 PM 0
Share

Your scripts look very complex for a unearthly reason.
Use the TouchDown and TouchUp to define that on the Button.
Very simple to look in the referance @ Well, honestly i would just bing it. Lol search the reference on Bing or Google with the ButtonDown xD.
I hoped I poped a idea into yur $$anonymous$$d.

0 Replies

· Add your reply
  • Sort: 

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Switching a GUIbuttons texture when holding your finger on it? 1 Answer

Android GUITexture Touch 0 Answers

Button reaction time problem 1 Answer

Why this simple code doesnt work? 0 Answers

Android Button Screen 1 Answer


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