예제 #1
0
        private void InternalDisplay(IEnumerable <SelectableOption> selectableOptions)
        {
            int x = 0;

            if (selectables != null)
            {
                Clean();
            }
            selectables = new List <GUISelectable>();
            foreach (SelectableOption option in selectableOptions)
            {
                GameObject    selectableGameObject = Instantiate(selectablePrefab, subpanel);
                RectTransform rect = (RectTransform)selectableGameObject.transform;
                rect.anchorMin = new Vector2((float)(x) / width, rect.anchorMin.y);
                rect.anchorMax = new Vector2((x + 1f) / width, rect.anchorMax.y);
                rect.offsetMin = new Vector2(12, 12);
                rect.offsetMax = new Vector2(-12, -12);
                GUISelectable selectable = selectableGameObject.GetComponent <GUISelectable>();
                selectable.xMin = x;
                selectable.xMax = x;
                selectable.y    = 0;
                selectable.DisplayIcon(option);
                selectables.Add(selectable);
                x++;
            }
            xMin = 0; xMax = 0; y = 0;
            Reposition();
        }
예제 #2
0
 void Select(GUISelectable selectable)
 {
     selector.gameObject.SetActive(true);
     selected = selectable;
     cost.Display(selectable.associatedOption.cost);
     flavorText.text = selectable.associatedOption.description;
     selector.Select((RectTransform)selectable.transform);
 }
예제 #3
0
        void Reposition()
        {
            int x = targetX.HasValue ? (width + targetX.Value) % width : xMin;
            int y = targetY.HasValue ? (height + targetY.Value) % height : this.y;

            GUISelectable selectable = Find(x, y);

            if (targetX != null)
            {
                xMin = selectable.xMin;
                xMax = selectable.xMax;
            }
            if (targetY != null)
            {
                y = selectable.y;
            }

            Select(selectable);

            targetX = null;
            targetY = null;
        }