Exemplo n.º 1
0
        /// <summary>
        /// Select objects based on input
        /// </summary>
        /// <param name="args"></param>
        public void ValueChanged(EventArgs <Vector2> args)
        {
            if (!_canMove || _selected == null)
            {
                return;
            }

            SelectableMenuItem next = null;
            float absX = Mathf.Abs(args.NewValue.x);
            float absY = Mathf.Abs(args.NewValue.y);

            if (absX > absY && absX > MoveThreshold)
            {
                next = args.NewValue.x > 0 ? _selected.OnRight : _selected.OnLeft;
            }
            else if (absY > absX && absY > MoveThreshold)
            {
                next = args.NewValue.y > 0 ? _selected.OnUp : _selected.OnDown;
            }

            if (next != null && next.enabled)
            {
                Select(next);
            }
        }
Exemplo n.º 2
0
    /// <summary>
    /// crea gli oggetti selezionabili.
    /// </summary>
    /// <param name="_item"></param>
    protected override void CreateMenuItem(ISelectable _item)
    {
        GameObject         newGO   = Instantiate(ButtonPrefab, MenuItemsContainer);
        SelectableMenuItem newItem = newGO.GetComponent <SelectableMenuItem>();

        newItem.SetData(_item);
    }
Exemplo n.º 3
0
    /// <summary>
    /// Crea un nuovo MenuItem per i button
    /// </summary>
    /// <param name="_item"></param>
    protected virtual void CreateMenuItem(ISelectable _item)
    {
        GameObject         newGO     = Instantiate(ButtonPrefab, MenuItemsContainer);
        SelectableMenuItem newButton = newGO.GetComponent <SelectableMenuItem>();

        newButton.SetData(_item);
        //newButton.onClick.AddListener(() => this.AddSelection(newButton.SelectionData));
    }
Exemplo n.º 4
0
        /// <summary>
        /// Select the given object
        /// </summary>
        /// <param name="selectable"></param>
        public void Select(SelectableMenuItem selectable)
        {
            if (selectable != null)
            {
                Debug.Log("Selecting: " + selectable.name);
                selectable.Select();

                if (SelectedChangedEvent != null)
                {
                    SelectedChangedEvent(selectable);
                }

                _selected = selectable;
            }

            StartCoroutine(WaitToMove(MoveDelay));
        }