コード例 #1
0
        public void Pin(OptionDefinition obj, int order = -1)
        {
            if (_uiRoot == null)
            {
                Load();
            }

            if (_pinnedObjects.ContainsKey(obj))
            {
                return;
            }

            var control = OptionControlFactory.CreateControl(obj);

            control.CachedTransform.SetParent(_uiRoot.Container, false);

            if (order >= 0)
            {
                control.CachedTransform.SetSiblingIndex(order);
            }

            _pinnedObjects.Add(obj, control);
            _controlList.Add(control);

            OnPinnedStateChanged(obj, true);
        }
コード例 #2
0
        protected void CreateCategory(string title, List <OptionDefinition> options)
        {
            options.Sort((d1, d2) => d1.SortPriority.CompareTo(d2.SortPriority));

            var instance = SRInstantiate.Instantiate(CategoryGroupPrefab);

            instance.CachedTransform.SetParent(ContentContainer, false);
            instance.Header.text = title;

            foreach (var option in options)
            {
                var control = OptionControlFactory.CreateControl(option, title);

                if (control == null)
                {
                    Debug.LogError("[SRDebugger.OptionsTab] Failed to create option control for {0}".Fmt(option.Name));
                    continue;
                }

                control.CachedTransform.SetParent(instance.Container, false);
                control.IsSelected           = Service.PinnedUI.HasPinned(option);
                control.SelectionModeEnabled = false;

                _options.Add(option, control);
                _controls.Add(control);
            }
        }