I tried to send this message in the scripting forum but got no answer so I’m trying here. It’s for an iPhon app anyway.
Ok, something so simple that’s driving me nuts. I have a sphere with my amin on it. I did the Import Setting thing to seperate my anim. Basically, idle, move left and move right. I also created 2 GUI textures. I placed one on the right, one on the left. All I’m trying to do is that when I press the left button it will play my left anim and same thing for the right. And if I press both buttons at the same time then it will play both animations at the same time. In this case it would not make much sense, the sphere would stay in the center but you can understand that I’m learning and the idea is not to make a sphere going left or right. Let’s say it would be more like if I press the left button a character will raise its left arm and same for the right.
I’m sure it’s quite simple but I’ve been going through the documentation for hours and I can’t figure it out.
Thanks,
Robert
“Damn it Jim! I’m an artist, not a programmer!” Smile
function OnGUI () {
if (GUI.Button (Rect (10,10,150,100), "Left Button")) {
animation.Play("Move Left");
}
}
I’m not sure what part you are hung up on, but try searching the scripting guide for animation to get lots of information on using custom animation files. If it’s the button that’s got you stuck, there is a fantastic GUI Scripting Guide in the help documents as well.
Hi Mattimus,
That generates a button automatically. What I’m trying to do is to use the script on a GUI texture.
Cheers,
Robert
you have to do a camera ray cast with the position of the first touch
there is a thread with an example implementation on the topic of GUITexture based buttons
there is no integrated way to do this, you will have to do your own gui and button logic
Really!?! There’s no easy way to just have a simple button (texture, not automatic button) that will play an animation?
I’m very surprised (and disappointed).
Thanks
Robert
Sure there is, thats what was posted above, GUI.Button, which you insisted on not using, althought it does what you want as you can specify the texture to be used on the button etc
At least from what you posted, you clearly wanted your own solution
A GUITexture is no button its just a texture thats always facing the camera and uses the GUILayer component assigned to the camera.
So if you want it to work as a button, you must implement button functionality to make it a button, as it is no button itself.
Ok! Great! It’s just that I didn’t know I could add a texture on these buttons. I’m happy how! Thanks for the help.
Junior Bob (I’m just starting… but then again, ask me anything about 3D animation and that’s a different story)
robertrioux.com