Ejemplo n.º 1
0
        /*
         * private IEnumerator WaitForChildToEnable()
         * {
         *  yield return new WaitForSeconds(0.05f);
         *  if (IsDisabled) yield break;
         *  if (!IsEnabled)
         *      yield break;
         *
         *  SetState(!IsChildActive());
         * }
         */

        public void OnPointerClick(PointerEventData eventData)
        {
            if (!CanEnable)
            {
                return;
            }

            if (IsRoot)
            {
                if (!IsEnabled)
                {
                    SetRootDrawn(true);
                    SetState(true);
                }
                else
                {
                    SetRootDrawn(false);
                    SetState(false);
                }

                return;
            }

            SetState(false);
            DisableParent();
            SetRootDrawn(false);
            JEMOperation.StartCoroutine(GlobalEnableTimeout());
            OnClick?.Invoke();
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Disables the active parents of this item.
        /// </summary>
        private void DisableParent()
        {
            var allParent = transform.GetComponentsInParent <JEMMenuItemElement>(true);

            foreach (var c in allParent)
            {
                if (c == this)
                {
                    continue;
                }
                if (c.IsEnabled)
                {
                    JEMOperation.StartCoroutine(c.DisableTimeout());
                    c.SetState(false);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Sets the active state of this item.
        /// </summary>
        internal void SetState(bool state)
        {
            if (IsEnabled == state)
            {
                return;
            }

#if DEBUG && MENUITEM_DEBUG
            Debug.Log($"JEMInterfaceMenuItem.SetState({state}) itemName_{FullPath}", this);
#endif
            IsEnabled = state;
            SetHighlight(state);

            var cellState = false;
            foreach (var unused in CellContentRight.transform)
            {
                cellState = true;
                break;
            }
            CellContentRight.SetActive(state && cellState);

            cellState = false;
            foreach (var unused in CellContentDown.transform)
            {
                cellState = true;
                break;
            }
            CellContentDown.SetActive(state && cellState);

            if (state)
            {
                return;
            }
            // Timeout next enable.
            JEMOperation.StartCoroutine(TimeoutForEnable());

            // Try to disable all children
            // DisableChildren();
        }