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 FlawlessDog · May 10, 2011 at 04:36 PM · guitouchtouchscreen

Touchscreens, Unity and all that hub-bub

I have inherited this Unity project. Most of the work has been done, and for the most part its all working. Got a few minor bugs other than this touchscreen issue, but is trying to get them all worked out.

The biggest, most important problem is this touchscreen issue, and is why I am here to see what I can learn. Seems like I'm not the only one with this problem. (Makes me feel a little better LOL ^_~)

Here is a link to a thread I posted to on the unity forums: http://forum.unity3d.com/threads/77569-UnityGui-useless-for-touchscreens

[quote] I am here to add me name to this list: Ish having the same issues with a touchscreen. Working on a mac-mini, elo touchscreen.

I got this project handed to me, and this seems the only thing left to do. Get this project to work on this touchscreen.

Only got 4 buttons that move my gameobject, and one for a help panel.

so, ok...after reading this thread, there seems only two options... 1. Get the mouse emulation to work correctly, (cool...how is that done?) or 2. write a plugin / use one of those that are already available for some panels. (where do I find one of these plugins?[and then after finding it, how to use it?])

It would be nice to see some kind of simple example of how this is done, please...

The funny thing I find here, is that when I test this project in Unity, it works fine on the touch screen. The problem occurs when I export the project into the stand alone player... Funny, huh? ^_~ [/quote]

I have been trying to learn unity on the fly here. I normally do flash action script, and html/css. So the java-scripts aren't too awful difficult. There's not been any c# scripts used so far...kindof weak in c# anyway, so good.

I'm not really sure of the questions I need to be asking. I do know this needs to get fixed, as the project has already been delivered in-spite of the bugs. They have been very cool about all this, and I want to fix this for them.

Project runs on a mac-mini with a elo 32 inch touch screen, and software.

Maybe my 4 control buttons, and the 5th menu button should be taken out of the unity GUIStyle thing and placed in a different way?

I admit it...I'ma kindof lost here.

PS...

I do feel this bit bears repeating...

The funny thing I find here, is that when I test this project in Unity, it works fine on the touch screen. The problem occurs when I export the project into the stand alone player... Funny, huh? ^_~

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 Jessy · May 10, 2011 at 05:47 PM 0
Share

"I'm not really sure of the questions I need to be asking." Sounds like a good post for the FORU$$anonymous$$!

1 Reply

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

Answer by FlawlessDog · May 11, 2011 at 06:43 PM

Ok, I got it...sortof.

The answer lay in this thread: http://answers.unity3d.com/questions/5382/can-i-change-guibutton-behaviour

You need to create the rect outside of the onGUI function first. Second, keep all your button functions in an upDate function, rather than in your onGUI function, as we had done here. The only thing that goes in the onGUI would be the GUIButton itself, which is created with the rect that was created outside on the onGUI function.

Now, we are coding in java-script rather than C# like the exampe I found, so had to re-write the code for that. Also, we are using a texture button, so those adjustments are included in my js conversion. This will give you a repeating button, which is what we needed. So, here's my version of the above example:

private var myButtonRect : Rect; private var myButtonTexture : Texture2D; function Awake() { myButtonRect= new Rect(0, 0, 200, 100); } function Update() { var fMouseX : float = Input.mousePosition.x; var fMouseY : float = Screen.height - Input.mousePosition.y; // Inverted Y

 if (ButtonRect.Contains(new Vector2(fMouseX, fMouseY)))
 {
     // Then all you have to do is code your button behaviour for each mouse action

     if (Input.GetMouseButton(0))
     {
         // Your code for mouse left click
     }

     if (Input.GetMouseUp(0))
     {
         // Your code for left button released
     }

     // And so on...
 }

} function OnGUI() { GUI.Button(myButtonRect, myButtonTexture, "Whatever"); }

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

No one has followed this question yet.

Related Questions

GuiTexture (Touch button) unfollow camera! 1 Answer

Working with screen's touch limit 0 Answers

Make object follow my finger (Touch)? 1 Answer

Reset touch Vector after movement 2 Answers

Not getting a response when a touch doesn't move with TKtouchkit 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