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 DigitalDogfight · Jan 11, 2012 at 11:59 PM · iosbuttonfpsyieldframes per second

iOS Polygon button not working with yield WaitForSeconds

Using Javascript in iOS. Trying to build a simple GUI system using Polygons with colliders as buttons. I've got the Input.touch ray firing just fine but any yield WaitForSeconds attached to it won't work. Currently, the polygon button does records the hit by scaling it a bit larger, but WILL NOT continue further. It should continue on to yield WaitForSeconds (.2), then put it back to it's original scale. Should look like a regular button press.

Also, I think this seems like an efficient way to handle the interface due to all button textures on one map rather than separate GUITextures or OnGUI. Also the fact that polygons scale properly with the screen size (3G,4G,iPad) while the others require extra code to scale properly. Let me know if it actually sucks for any performance reasons.

Code attached to camera to draw a ray:

 function Update () 
 {
     for (var Touch : Touch in Input.touches) 
     {
         if (Touch.phase == TouchPhase.Began) 
         {
             var ray = Camera.main.ScreenPointToRay (Touch.position);
             
             Debug.DrawRay (ray.origin, ray.direction * 200, Color.yellow);
             var hit : RaycastHit;
             if (Physics.Raycast (ray, hit)) 
             {
                 hit.collider.SendMessageUpwards("Activate", SendMessageOptions.DontRequireReceiver); 
             }
         }
     }
 } 

Code attached to polygon button: Activate_Button.js

 var scaleFactor = 1.1;
 var thisScaleX = 0.0;
 var thisScaleY = 0.0;
 
 function Awake()
 {
     //Record the original size of polygon
     thisScaleX = transform.localScale.x;
     thisScaleY = transform.localScale.y;
 }
 function Activate () 
 {    
     // THIS WORKS FINE...
     transform.localScale = Vector3(thisScaleX, thisScaleY,1) * scaleFactor;
 
     // … BUT WON'T CONTINUE ON TO THIS.
     yield WaitForSeconds (0.2);    
     transform.localScale = Vector3(thisScaleX, thisScaleY,1);
     Debug.Log("Button Pressed")
 }

I have tried numerous other ways including StartCoroutine, unhiding another pre-scaled poly button, etc. and nothing works. Seems to me that the polygon button script only fires for the exact frame on which the ray hits it. Since yield has to do with a longer time factor, it is disregarded. At least that's all I can think of.

Any words of advice are greatly appreciated.

- UPDATE -

After some tests, I noticed that Frames Per Second are not registering in some of my scenes. This problem is a direct result of yield WaitForSeconds not working. See the link below for tests I performed to figure out that they weren't registering. I still DO NOT have a direct fix aside from exporting all my scenes and importing into a new project file.

http://answers.unity3d.com/questions/204885/frame-counter-not-registering.html

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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Frame counter not registering - Component missing? 1 Answer

Low FPS rate. Can't find the problem. Followed Unity's Guide 2 Answers

Mobile GUI Buttons 1 Answer

On iOS, how do I fade out music when the user presses the home button? 1 Answer

How do I set up a GUITexture as a functional button? 4 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