I am new to Unity and I am attempting to make my first User Interface (UI) with 3D objects that I modeled in 3D Studio Max and imported into the editor as FBX files. At the moment I have a background image in and my 3D Play button in place as well. Now, I am looking to get the Play button to react to my Left Mouse Click (only when my cursor is on the button itself, however), and I am trying to get it to rotate 180 degrees in reaction to the click.
I have used JavaScript so far and I can’t seem to get it to work. I’ve also checked out a lot of tutorials and the scripting references, but, as I said, I’m relatively new to Unity and I can’t quite find the code to do what I am looking for. I thought that, perhaps, one could offer some help with this matter.
I think it would be best to perform a ray cast to see if the mouse has clicked the play button(tag the button as “play” or something similar). Use an if statement to return a boolean as true if it hit the play button. Attach a script to the play button and if the boolean is true then transform.rotate the button 180.
Sorry I don’t know Javascript so can’t write up any decent scripts for you
Ahh I miss read that you didn’t want it to click. Yeah JRavey is correct with the MouseOver() function. Intead of the ray cast just use OnMouseOver() to check if it’s over the button and if so set the boolean to true. Just make sure you have a script on the button to rotate when the boolean is true and it should work
Awesome, I wasn’t sure if the MouseDown would apply even if I wasn’t on the button, but I’m messing around with it now and I think I’m making some progress on it thanks to all of the input.
Thank you kindly, I’ve got a mesh collider on there now, so I’m working on the rotation and click-ability. The avatar is from the Flash version of the game I’m trying to make this menu for, so hopefully it comes to fruition soon enough.