How can I put buttons on a Cube?
Please help me I've been trying to figure out this for a month now...Yeah embarrassing... Well I have a cube with a script for rotating it and my problem is that I wan't to put buttons or something similar like "Piano Tiles" on the cube and still use my script for rotation. Please help me solve this issue I am new to game developing and C#.
Heres my code:
private float rotationSpeed = 8.0F;
private float lerpSpeed = 1.0F;
private Vector3 theSpeed;
private Vector3 avgSpeed;
private bool isDragging = false;
private Vector3 targetSpeedX;
void OnMouseDown() {
isDragging = true;
}
void Update() {
if (Input.GetMouseButton(0) && isDragging) {
theSpeed = new Vector3(-Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"), 0.0F);
avgSpeed = Vector3.Lerp(avgSpeed, theSpeed, Time.deltaTime * 1);
} else {
if (isDragging) {
theSpeed = avgSpeed;
isDragging = false;
}
float i = Time.deltaTime * lerpSpeed;
theSpeed = Vector3.Lerp(theSpeed, Vector3.zero, i);
}
transform.Rotate(Camera.main.transform.up * theSpeed.x * rotationSpeed, Space.World);
transform.Rotate(Camera.main.transform.right * theSpeed.y * rotationSpeed, Space.World);
Piano Tiles is all UI, theres no 3D elements to the game at all, and each UI element already has triggers/colliders that fire with raycasting (technically), thays how it already registers common events like clicking down, clicking up/releasing a click on a element, mousing over something, mousing off something, etc...
If you want to apply that same logic to a 3D object, that object needs to have a collider on it, and then you can use IPointer events to register those things, or use the Event Trigger (I think its called, I dont have Unity in front of me right now), component on the cube, and manually code similar events (just regular void functions, that youd set for specific triggers - they can also take up to 1 parameter that is a common datatype, such as int, string, bool, a custom script, etc)
@Dibbie So in order for me to stick like piano tiles on a cube can you post links to tutorials on how to make colliders and IPointer events and Triggers. I am new to c# and unity this is my first game... Thank you for helping me develop my first game...