how would i change the colour of an image once I've hovered over a button?
hey so I'm new to unity and I'm trying to make a cool but simple menu for my game ... how would i change the colour of an image once I've hovered over a button? i have already managed to know when i have enter/exited and clicked the button but i have no clue how to change the colour for the image.
I don't know how to explain it much more. for example i have icons for play, settings and volume. what I want to happen is when i hover the mouse over one of the button the bar that i have put across all of them i want to make it change colour.
in the picture above I'm showing what i mean by the bar.
in the above photo i have my mouse over the button and it is showing the highlighted colour that i have set for it. this is the type of effect i am looking for but with using a separate button from the bar.
this is the code i have so far. I've been looking everywhere for an answer over the past week and I'm starting to get super annoyed, it's probably something simple but i don't have the knowledge for it yet.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ButtonTest : MonoBehaviour {
public Image MenuBar;
public void OnClick(){
Debug.Log ("Clicked!");
}
public void OnEnter(){
Debug.Log ("YAY!");
}
public void OnExit(){
Debug.Log ("Aw, sad now");
}
}
so i know this code works when i hover over the button cause i have set the event triggers to look for these commands. but immmmmmmmmmmmmmmmm sooooooo stuck. please help :)
You'd probably use IPointerEnterHandler Then use GetComponent to get the color of the button.
This is how you'd use it in javascript (you'll have to translate it to C#):
public class Items extends $$anonymous$$onoBehaviour implements IPointerEnterHandler {
// i think you can insert the getcomponent call here
function OnPointerEnter(eventData : PointerEventData){
// variable(the getcomponent var).color or something like that. I haven't done it with colors, so i'm not too certain, but this is how i would do it.
}
} https://docs.unity3d.com/ScriptReference/EventSystems.IPointerEnterHandler.OnPointerEnter.html