Hey! I don’t use to ask in the forums but this time I could not find an answer, this new UI thing and the lack of information is killing me XD, ok basically my problem, as you know there is a component called button, I assigned it to a text to make a sort of selectable default text in a list of items, the thing that the list is a pop up menu, so once I select an option I click ok (another button) and that menu is destroyed and info stored in a variable, what I want is that if the menu pop ups again the previous choice appears as clicked! so the user can see it was the last selected object, so how can I change the state(or whatever is called, don’t know much about that) by code?.
Some facts:
-The pop up menu is a prefab, not generated item by item, I see it very hard to do with the new system.
-I could just change color of the text when it first starts, however buttons have several colors so I must set somehow the state to clicked :S.
Well, any sort of help is very appreciated. Thanks.
Is there any particular reason why you are destroying the pop up menu? Instead of destroying the prefab, you could set it to inactive and then reactivate it when you need it. Then whenever a menu item(a button) is clicked you can set the button’s interactable flag as false, meaning you can no longer interact(click or select) with this button.
someButton.interactable = false;
http://docs.unity3d.com/ScriptReference/UI.Selectable-interactable.html
Well, that could work, the real thing was just higlighting the previous clicked option, setting as inactive is a way to do it too, because all I wanted really was just click the button by code. Actually I don’t know almost anything about new Ui coding, the documentation is really not good so far about that, is a real pain to look over each minor thing I need to get done. Thanks I’ll see how it results.
OMG it was so f*****g stupid XD, well if anyone feel lost, this code snipped does everything I needed. It is in documentation, I just found it by random browsing though it.
#pragma strict
// required when using UI elements in scripts
// Required when using Event data.
public var myInputField;
//Do this OnClick.
public function SaveGame() {
//Makes the Input Field the selected UI Element.
myInputField.Select();
}