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 reptilebeats · Jan 17, 2012 at 02:41 PM · mousetouch

touch input

hi im testing my game with an iphone and have noticed that mouse down works fine on the device, but i want to use touch as i could be touching two things at any one time.

basically i have up,down,left,right as gui buttons and need to be able to say touch up and left at the same time,

will mousedown work for this or do i need to use touch. if so what is the proper code to say if i touch this gui, then do whatever as i tried a few things and nothing is working.

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 dannyskim · Jan 17, 2012 at 07:24 PM 0
Share

are you using OnGUI and GUI.button? Reason I ask is that using Unity's GUI system first of all on a mobile device is a huge no-no. Second of all, mouse down will not work, you will have to use Touch input to detect multi-touch on mobile devices.

avatar image reptilebeats · Jan 18, 2012 at 02:25 PM 0
Share

well i tried on gui but no response unless i used on mouse down, i would like to if i cant use gui mark out an area where if i touch changes the gui texture and does the action.

so pretty much faking me pressing on gui, but visually looks as if i am

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by reptilebeats · Jan 19, 2012 at 12:51 AM

this is the sort of code i was looking for nice and simple...

function Update(){

 if (Input.touchCount >0){
     var touch : Touch = Input.touches[0]; 
 }
 
 if(touch.phase == TouchPhase.Stationary && guiTexture.HitTest(touch.position)){
    Debug.Log("hi");
     
 }
 
 

}

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
1

Answer by kaimelar · Jan 17, 2012 at 08:44 PM

Input.touchCount = > You can check how much finger on the screen Ex:

  if(Input.touchCount == 2){
    Debug.Log("Two finger on the screen");

Input.GetTouch(0); => you can get touch data 0 or 1;Ex:

      Touch t0 = Input.GetTouch(0);
      Vector3 t0Pos = new Vector3(t0.deltaPosition.x, t0.deltaPosition, 0);
      Debug.Log(t0Pos);

t0.phase => This is your finger status Ex:

 if(t0.phase == TouchPhase.Moved)
    Debug.Log("Your finger is moving now");

These are important function.If you any problem, ask again here.

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

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

OnMouseDown is checked when build for Android 2 Answers

A node in a childnode? 1 Answer

Raycast based on a Rect? 1 Answer

Touch / Mouse tracing 1 Answer

How to select an object with TOUCH and change its animation 2D 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