|
Greetings, guys. While i'm working on my Unity3d Android project, i bumped into one thing, that I can't do properly. I'm creating an interface, and I have 2 GUITextures, each one represents a button. UP and DOWN. When I tap on one, animation plays well, but Unity does not count another GUITexture as separate button. So when I press it, it works like first button. Here is some code: Code for button UP
Code for button DOWN Im fact, I know, that i need to use "hit.test" method, but I dunno how to make it right. Thanks for your attention
(comments are locked)
|
|
I have another question (as I deal with previous). This script works only once, I mean when I want to play animation again and tap the button...nothing happend. What I need to add to my script? function Update() {
(comments are locked)
|
|
If you use the GUI.Button you will have more control over what buttons are being touched. The buttons will automatically react to touch inputs, which is really nice because you don't have to constantly be checking for a touch input. This is what I would do. It is pretty much recommended across the board to not use OnGUI in any mobile app / game developed in Unity. There is way too much overhead associated with this method. If you are going to use Unity's GUI System, the only reasonable option for mobile platforms is using GUITextures as they are considered GUIElements. GUIElements are not associated with OnGUI and thus do not exhibit the overhead of OnGUI.
Feb 09 '12 at 08:06 PM
dannyskim
(comments are locked)
|
dannyskim, your method does not work fine. Script plays animation "UP" when i tap any part of my screen.
Feb 10 '12 at 12:26 PM
Rocotos
How are you using it? You need to have at least two objects, and you need to name them uniquely. What part of the code isn't working?
Feb 10 '12 at 12:29 PM
syclamoth
Well, I have 2 GUITextures called "up" and "down". I attach this script to each one, but change this line: case "guiTexture_name1" on case "up" and case "down". case "up": animation["UP"].speed= 1.0; animation.Play("UP"); case "down": animation["UP"].speed= -1.0; animation.Play("UP"); But script "down" doesn't work at all and if I press anywhere on my touchscreen - animation UP start playing.
Feb 10 '12 at 01:12 PM
Rocotos
(comments are locked)
|
