コード例 #1
0
        private void Init(GameObject elementsContainer, ISelectable startSelectable)
        {
            foreach (var del in elementsContainer.GetComponentsInChildren <ISelectionViewDelegate>())
            {
                del.HandleSelectionView(this);
            }

            selectables_ = elementsContainer.GetComponentsInChildren <ISelectable>();
            if (selectables_.Length <= 0)
            {
                Debug.LogError("ElementSelectionView - needs selectables??");
            }

            CoroutineWrapper.DoAtEndOfFrame(() => {
                selectorTransform_ = ObjectPoolManager.CreateView(GamePrefabs.Instance.SelectorPrefab, viewManager: GameViewManagerLocator.Selector).GetComponent <RectTransform>();

                if (player_ != null)
                {
                    // hacky way to get a color
                    selectorTransform_.GetComponentInChildren <Image>().color = GameConstants.Instance.PlayerSkins[player_.Index()].UIColor;
                }

                if (startSelectable != null)
                {
                    SetCurrentSelectable(startSelectable, animate: false);
                }
                else
                {
                    DefaultSelectableMarker defaultSelectableMarker = elementsContainer.GetComponentInChildren <DefaultSelectableMarker>();
                    if (defaultSelectableMarker != null)
                    {
                        SetCurrentSelectable(defaultSelectableMarker.GetComponent <ISelectable>(), animate: false);
                    }
                    else
                    {
                        SetCurrentSelectable(selectables_[0], animate: false);
                    }
                }

                Localization.OnCultureChanged += HandleLocalizationChanged;
            });
        }