public void ChangeState(CanInspect.State _state) { switch (_state) { case CanInspect.State.Default: ui_BackgroundImage.sprite = Background_Default; break; case CanInspect.State.PickedUp: ui_BackgroundImage.sprite = Background_PickedUp; break; } State = _state; }
//public void ToggleWindow(InteractiveObject _io, InteractiveObject.State _state, WindowType _type) { // currently only support for 1 window, but maybe more later? // if (currentInfoWindow != null && currentInfoWindow.OwnerIO == _io) // CloseCurrentInfoWindow(); // else // OpenNewWindow(_io, _state, _type); //} public void OpenNewWindow(CanInspect _inspectable, CanInspect.State _state, WindowType _type) { int _index = currentInfoWindows.FindIndex(x => x.User == _inspectable); UIInfoWindow _currentWindow = null; if (_index > -1) { _currentWindow = currentInfoWindows[_index].Window; if (_currentWindow.OwnerInspectable == _inspectable) { if (_state != _currentWindow.State) { _currentWindow.ChangeState(_state); } return; } CloseInfoWindow(_inspectable, _index); // not sure if needed } switch (_type) { case WindowType.Basic: _currentWindow = ComponentWindow_Main; break; case WindowType.Basic_SecondWindow: _currentWindow = ComponentWindow_Sub; break; case WindowType.ComponentHolder_x6: _currentWindow = ComponentHolderWindow_x6; break; case WindowType.ComponentHolder_x9: _currentWindow = ComponentHolderWindow_x9; break; case WindowType.ComponentHolder_15: _currentWindow = ComponentHolderWindow_x15; break; case WindowType.ComponentHolder_x24: _currentWindow = ComponentHolderWindow_x24; break; } // make sure no on else is using this window for (int i = 0; i < currentInfoWindows.Count; i++) { if (currentInfoWindows [i].Window == _currentWindow) { CloseInfoWindow(currentInfoWindows[i].User, i); } } ComponentObject _trackedComponent = null; switch (_type) { case WindowType.Basic: case WindowType.Basic_SecondWindow: _trackedComponent = _inspectable.GetComponent <ComponentObject>(); break; case WindowType.ComponentHolder_x6: case WindowType.ComponentHolder_x9: case WindowType.ComponentHolder_15: case WindowType.ComponentHolder_x24: currentComponentHolder = _inspectable.GetComponent <ComponentHolder>(); // set button-names to be the same as in the component-slots ComponentObject.ComponentType _compType; int _compTypeID; for (int i = 0; i < _currentWindow.Buttons.Length; i++) { _compType = currentComponentHolder.ComponentSlots[i].SlotType; _compTypeID = currentComponentHolder.ComponentSlots[i].SlotTypeID; _currentWindow.Buttons[i].GetComponentInChildren <Text>().text = ComponentInfoManager.Instance.AllComponentsInfo[_compType][_compTypeID].Name; } break; } _currentWindow.UI_Image.sprite = _inspectable.Selected_Sprite; _currentWindow.UI_Name.text = _inspectable.Selected_Name; _currentWindow.UI_Desc.text = _inspectable.Selected_Desc; UITrackObject _tracker = _currentWindow.GetComponent <UITrackObject>(); if (_tracker != null) { _tracker.trackTransform = _inspectable.transform; } _currentWindow.ChangeState(_state); _currentWindow.ShowWindow(_inspectable, _trackedComponent); currentInfoWindows.Add(new InfoWindowUser(_currentWindow, _inspectable)); UpdateButtonGraphics(_inspectable); }