Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 JumboShrimps · Nov 03, 2015 at 05:25 PM · buttonpositionmobiletouch controls

why doesn't my touch-position conditional statements work for mobile app?

So i created a texture to represent my start button and added 4 empty game objects named LB, RB, TB, and BB (leftborder, rightborder, topborder, bottomborder) as children of the start button texture and aligned them respectively (ex: leftborder aligned with the left border of my texture). I then set the conditional statement down below however it is not executing. could this be because Input.GetTouch (0).position.x returns coordinates values between 0-1 while my border transforms have -position values? *I've already checked that the co-routine works

 GameObject startbutton01 = new GameObject ();
 GameObject startbutton02 = new GameObject ();
 public GameObject startbutton1;
 public GameObject startbutton2;
 public Transform startbuttonspawn;
 private bool Busy = false;
 public Transform LB;
 public Transform RB;
 public Transform TB;
 public Transform BB;

 void Start () {
 }

 void Update () {
 Touch touch = Input.GetTouch (0);

     if (Input.touchCount > 0 && touch.phase == TouchPhase.Began && Busy == false &&                                    touch.position.x >= LB.position.x && touch.position.x <= RB.position.x && touch.position.y <= TB.position.y && touch.position.y >= BB.position.y) {
     
         StartCoroutine (buttonAnim());
     } 

 }

 IEnumerator buttonAnim(){
     Busy = true;
     Destroy (startbutton01);
     Destroy (startbutton02);
     startbutton01 = Instantiate (startbutton2, startbuttonspawn.position, startbuttonspawn.rotation) as GameObject;
     yield return new WaitForSeconds (1);
     startbutton02 = Instantiate (startbutton1, startbuttonspawn.position, startbuttonspawn.rotation) as GameObject;
     Destroy (startbutton01);
     Busy = false;
 }

}

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 JumboShrimps · Nov 02, 2015 at 02:35 PM 0
Share

so ive learned a couple things since last post, that (0,0) in the screen space coordinate system is bottom-left while the information returned by Input.GetTouch (0).position.x may have (0,0) at topleft, i tried to look for this in the documentation but failed so i'm not sure and need help **even though i'm deriving the coordinates from empty gameobjects attached to the texture, does this still give me a different coordinate system value when being run on a phone?


all these different coordinates systems is giving me a real headache (especially since i cant directly test my app on my phone and have to do it manually). so i need conformation on the following things: *to position things in phone i must use 0-1 coordinate system with (0,0) originating bottom-left? *Unity screen space uses pixel coordinate system with (0,0) originating top-left? *to potentially position something correctly on my phone i would have to, first, convert the values so both coordinate system's (0,0) are bottom-left, second, i would have to convert the number of pixels in the pixel coordinate system to 0-1 to match the phone positioning system of phone.?

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to position elements on scene 0 Answers

Button Navigation none - not working with touchscreen 0 Answers

Moving character with touch controls. 1 Answer

How to Change Cameras through a Canvas Button 2 Answers

Change the position of a UI component through pressing a UI Button 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