コード例 #1
0
        private void PriorityButtonDownClicked(SpecializationDetailsPanel panel)
        {
            if (Input.GetButton("Shift"))
            {
                panel.SpecializationToggle.Value++;
            }
            else
            {
                int index = panel.transform.GetSiblingIndex();
                SpecializationDetailsPanel nextPanel = this.Content.GetChild(index + 1).GetComponent <SpecializationDetailsPanel>();

                bool mustPush = panel.SpecializationToggle.Value == nextPanel.SpecializationToggle.Value;
                panel.SpecializationToggle.Value++;
                nextPanel.GetComponentInChildren <OrderableToggle>().Value--;

                if (mustPush)
                {
                    for (int i = 0; i <= index; i++)
                    {
                        this.Content.GetChild(i).GetComponent <SpecializationDetailsPanel>().SpecializationToggle.Value--;
                    }
                }
            }

            this.OrderDetailPanels();
        }
コード例 #2
0
        /// <summary>
        /// Initializes the panel
        /// </summary>
        /// <param name="pType">The profession type</param>
        /// <param name="specializations">Specializations of the profession</param>
        /// <param name="upButton">The template of the Up button</param>
        /// <param name="downButton">The template of the Down button</param>
        /// <param name="toggle">The template of the Toggle</param>
        public void Init(ProfessionType pType, List <SpecializationDescriptor> specializations)
        {
            this.ProfessionType = pType;

            //For each specialization, create a detail panel
            foreach (var spec in specializations)
            {
                GameObject specObj = GameObject.Instantiate(this.DetailsPanelTemplate, this.Content);
                SpecializationDetailsPanel panel = specObj.GetComponent <SpecializationDetailsPanel>();
                panel.Init(this, spec, specializations.Count - 1);
                panel.SpecializationToggle.UpButton.onClick.AddListener(() => PriorityButtonUpClicked(panel));
                panel.SpecializationToggle.DownButton.onClick.AddListener(() => PriorityButtonDownClicked(panel));
                DetailPanels.Add(panel);
            }

            OrderDetailPanels();
        }