1
NGUI 3 Support / Using NGUItools.SetActive to hide and unhide buttons breaks their functionality.
« on: July 23, 2014, 11:09:11 AM »
Hi,
I'm trying to hide and unhide context-sensitive functionality based on what the player has selected.
The logic is working correctly to identify the selections as my debug.logs are going off when expected. Also, the buttons are hiding and unhiding, but when they are hidden through any way (disabling in unity editor with the checkbox, disabling with NGUItools.setactive) and re-enabled, they reappear visually, but no longer respond to mouseovers or clicks etc.
The code I'm using is here:
The button just completely ceases to function, but if I start the game with them enabled, they work until they have been disabled and re-enabled at least once. MoveOrderButton and AttackOrderButton are the gameobjects that have the UISprite, UIButton and BoxCollider components on them that make them functional as a button until disabled and re-enabled.
Edit:
List of things I have checked:
None of the script components or the collider get/remain disabled when re-activating.
I'm trying to hide and unhide context-sensitive functionality based on what the player has selected.
The logic is working correctly to identify the selections as my debug.logs are going off when expected. Also, the buttons are hiding and unhiding, but when they are hidden through any way (disabling in unity editor with the checkbox, disabling with NGUItools.setactive) and re-enabled, they reappear visually, but no longer respond to mouseovers or clicks etc.
The code I'm using is here:
- // First check if the list is empty. If it is, we want no context sensitive commands to appear at all.
- if (_selection.Count <= 0)
- {
- NGUITools.SetActive(MoveOrderButton,false);
- NGUITools.SetActive(AttackOrderButton,false);
- return;
- }
- // Check what is selected.
- foreach (GameObject g in _selection)
- {
- if (g.tag == "Units")
- {
- Debug.Log("Selection is units.");
- // Set up the appropriate Order buttons.
- NGUITools.SetActive(MoveOrderButton,true);
- NGUITools.SetActive(AttackOrderButton,true);
- }
- }
The button just completely ceases to function, but if I start the game with them enabled, they work until they have been disabled and re-enabled at least once. MoveOrderButton and AttackOrderButton are the gameobjects that have the UISprite, UIButton and BoxCollider components on them that make them functional as a button until disabled and re-enabled.
Edit:
List of things I have checked:
None of the script components or the collider get/remain disabled when re-activating.