Hello everyone,
I’m really confused about the new Unity 5 menu.
I don’t know how to switch on and off visibility, or changing color.
I’ve already test with some scripts using Google, but everyone only talk about the Unity 4 GUI system.
It’s a for a basic menu, where you use arrow key, to Highlight the selection, and move it a bit. I’ve thinked about using One Empty object, with a variable. It would send messages. but yeah, I don’t know what to do for now as I can’t do a thing with these new UI…
If you have the answer, thank you a lot.
The new UI system was added in Unity 4.6, so it may or may not be what they’re talking about. I’d suggest you take a look at the Unity tutorials for the UI system. It has overviews of the components, as well as Live Sessions (recorded streams to an audience, usually around an hour long each) that focus on the UI, including scripting.
And don’t forget the online scripting manual:
http://docs.unity3d.com/ScriptReference/UI.Button.html
http://docs.unity3d.com/ScriptReference/UI.Text.html
Here’s a quick script that shows the very basics of accessing the UI elements:
using UnityEngine;
using UnityEngine.UI;//Needed for access to UI variable and class methods
public class UIBasics : MonoBehaviour
{
public Text textUI;
public Button buttonUI;
public Color buttonColorSelected = Color.green;
public Color buttonColorNormal = Color.white;
ColorBlock buttonColors;
void Start()
{
textUI.text = "Sample text here.";
textUI.color = Color.red;
buttonColors.normalColor = buttonColorNormal;
buttonColors.pressedColor = buttonColorSelected;
buttonUI.colors = buttonColors;//Can't set individual colors directly, need to set through a ColorBlock
}
}