This is so weird because Visual Studio says that Image does not contain a definition for color, but clearly it does.
Here’s the whole code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class RadialMenu : MonoBehaviour
{
public Transform radialMenu;
public List<RadialButton> buttons = new List<RadialButton>();
private Vector2 mousePos;
private int selectedItem;
private int oldItem;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
UpdateMenu();
}
void UpdateMenu()
{
//Gets the mouse position between 0,1
mousePos = new Vector2(Input.mousePosition.x / Screen.width, Input.mousePosition.y / Screen.height);
//Gets the angle the mouse is in
float angle = ((Mathf.Atan2(.5f, 0) - Mathf.Atan2(mousePos.y - .5f, mousePos.x - .5f)) * Mathf.Rad2Deg) % 360;
selectedItem = (int)(angle / (360 / buttons.Count));
if(selectedItem != oldItem)
{
buttons[oldItem].image.color = buttons[oldItem].normalColor;
}
}
}
public class RadialButton
{
public string name = "Button" + Random.Range(0, 100);
public Image image;
public Color normalColor = Color.gray;
public Color highLightedColor = new Color(.4f, .4f, .4f, 1);
}