/*--------------------------------------------------------------------------------------------*/
        public override void OnInspectorGUI()
        {
            vData = (HoverItemData)target;

            serializedObject.Update();
            DrawItems();
            serializedObject.ApplyModifiedProperties();
        }
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateItem(HoverItemData pItemData, bool pPreventHighlight)
        {
            HoverItemHighlightState highState = pItemData.gameObject
                .GetComponent<HoverItemHighlightState>();

            if ( highState == null ) {
                return;
            }

            UpdateHighState(highState, pPreventHighlight);
        }
        /*--------------------------------------------------------------------------------------------*/
        private void FadeItem(HoverItemData pItemData, float pAlpha)
        {
            HoverAlphaRendererUpdater rendUp =
                pItemData.gameObject.GetComponentInChildren<HoverAlphaRendererUpdater>();

            if ( rendUp == null ) {
                return;
            }

            float currAlpha = (pItemData.IsEnabled ? rendUp.EnabledAlpha : rendUp.DisabledAlpha);

            rendUp.Controllers.Set(HoverAlphaRendererUpdater.MasterAlphaName, this);
            rendUp.MasterAlpha = Mathf.Lerp(0, currAlpha, pAlpha);
        }
Ejemplo n.º 4
0
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateWithLatestItemTypeIfNeeded()
        {
            if ( _ItemType == vPrevItemType ) {
                return;
            }

            HoverItemData newData = BuildData(_ItemType);
            TransferData(newData);

            DestroyImmediate(_Data);
            _Data = newData;

            if ( OnTypeChanged != null ) {
                OnTypeChanged.Invoke(this);
            }

            vPrevItemType = _ItemType;
        }
Ejemplo n.º 5
0
        /*--------------------------------------------------------------------------------------------*/
        private HoverItemData TransferData(HoverItemData pDataToFill)
        {
            HoverItemData oldData = _Data;
            HoverItemData newData = pDataToFill;

            if ( oldData == null ) {
                return newData;
            }

            newData.AutoId = oldData.AutoId;
            newData.IsAncestryEnabled = oldData.IsAncestryEnabled;
            newData.IsAncestryVisible = oldData.IsAncestryVisible;
            newData.Id = oldData.Id;
            newData.Label = oldData.Label;
            newData.IsEnabled = oldData.IsEnabled;
            newData.IsVisible = oldData.IsVisible;

            SelectableItem oldSelData = (oldData as SelectableItem);
            SelectableItem newSelData = (newData as SelectableItem);

            if ( oldSelData == null || newSelData == null ) {
                return newData;
            }

            newSelData.OnSelectedEvent = oldSelData.OnSelectedEvent;
            newSelData.OnDeselectedEvent = oldSelData.OnDeselectedEvent;
            //newSelData.OnSelected += oldSelData.OnSelected;
            //newSelData.OnDeselected += oldSelData.OnDeselected;

            SelectableItemBool oldSelBoolData = (oldData as SelectableItemBool);
            SelectableItemBool newSelBoolData = (newData as SelectableItemBool);

            if ( oldSelBoolData != null && newSelBoolData != null ) {
                newSelBoolData.Value = oldSelBoolData.Value;
                newSelBoolData.OnValueChangedEvent = oldSelBoolData.OnValueChangedEvent;
                //newSelBoolData.OnValueChanged += oldSelBoolData.OnValueChanged;
            }

            SelectableItemFloat oldSelFloatData = (oldData as SelectableItemFloat);
            SelectableItemFloat newSelFloatData = (newData as SelectableItemFloat);

            if ( oldSelFloatData != null && newSelFloatData != null ) {
                newSelFloatData.Value = oldSelFloatData.Value;
                newSelFloatData.OnValueChangedEvent = oldSelFloatData.OnValueChangedEvent;
                //newSelFloatData.OnValueChanged += oldSelFloatData.OnValueChanged;
            }

            return newData;
        }
Ejemplo n.º 6
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void BuildDataIfNeeded()
        {
            if ( _Data == null ) {
                _Data = gameObject.GetComponent<HoverItemData>();
            }

            if ( _Data == null ) {
                _Data = BuildData(_ItemType);
            }
            else if ( FindDuplicateData() ) {
                _Data = Instantiate(_Data); //handle duplication via Unity editor
            }
        }
Ejemplo n.º 7
0
        /*--------------------------------------------------------------------------------------------*/
        private void DestroyData(HoverItemData pData, HoverItemData pIgnoreNewData)
        {
            gameObject.GetComponents(vDataComponentBuffer);

            for ( int i = 0 ; i < vDataComponentBuffer.Count ; i++ ) {
                HoverItemData data = vDataComponentBuffer[i];

                if ( data == pIgnoreNewData ) {
                    continue;
                }

                if ( data != pData ) {
                    Debug.LogWarning("Removed unexpected "+typeof(HoverItemData).Name+": "+data, this);
                }

                DestroyImmediate(data, false);
            }
        }