public void highlight() { _highlighted = true; _wasActiveLastFrame = true; for (int i = 0; i < gameObject.transform.childCount; i++) { ButtonBehavior button = gameObject.transform.GetChild(i).GetComponent(typeof(ButtonBehavior)) as ButtonBehavior; button.changeState(ButtonBehavior.State.HIGHLIGHT); } }
// Update is called once per frame void Update() { if (_childLevel != null) //The child menu has deactivated itself. Bubble up. { LevelBehavior child = (_childLevel.GetComponent(typeof(LevelBehavior)) as LevelBehavior); if (child == null || child.cleared == true) { _childLevel = null; clearSelf(); return; } } if (_leapManager.pointerPositionScreenToWorld.x >= _minX && _leapManager.pointerPositionScreenToWorld.x <= _maxX) { _wasActiveLastFrame = true; if (_childLevel != null) { (_childLevel.GetComponent(typeof(LevelBehavior)) as LevelBehavior).clearChild(); } for (int i = 0; i < gameObject.transform.childCount; i++) { ButtonBehavior button = gameObject.transform.GetChild(i).GetComponent(typeof(ButtonBehavior)) as ButtonBehavior; button.changeState(ButtonBehavior.State.NORMAL); if (button.selected) { if (button._nextLinkage != null && button._selectionAction == "") { _lastSelectedOptionButton = null; if (button != _spawnedChildOrigin) { spawnLevel(button); } else { (_childLevel.GetComponent(typeof(LevelBehavior)) as LevelBehavior).highlight(); } } else if (button._selectionAction != "" && button._nextLinkage == null) { clearChild(); _lastSelectedOptionButton = button; } } } } else if (_wasActiveLastFrame) { if (_highlighted) { _highlighted = false; } else { _wasActiveLastFrame = false; if (_lastSelectedOptionButton != null && _leapManager.pointerPositionScreenToWorld.x > _maxX) { //Send button action up to a static listener: //... //Then do this: _lastSelectedOptionButton.changeState(ButtonBehavior.State.SELECTED); clearSelf(_lastSelectedOptionButton); } else { for (int i = 0; i < gameObject.transform.childCount; i++) { ButtonBehavior button = gameObject.transform.GetChild(i).GetComponent(typeof(ButtonBehavior)) as ButtonBehavior; if (button == _spawnedChildOrigin) { button.changeState(ButtonBehavior.State.SELECTED_PATH); } else { button.changeState(ButtonBehavior.State.DISABLED); } } } } } }