コード例 #1
0
        private void SetSection(int index)
        {
            int preButtonIndex = 0;

            Section[] sections  = allSectionsInLayers[currentLayer].ToArray();
            int       lastIndex = currentSectionIndex < 0 ? 0 : currentSectionIndex;

            lastIndex = index >= 0 ? lastIndex : -1;
            int targetIndex = currentSectionIndex;

            if (CurrentSection != null)
            {
                preButtonIndex = CurrentSection.CurrentButtonIndex;
                CurrentSection.SetCurrentButton(-1);
            }

            targetIndex = sections.GetClampedIndex(index);
            SetCurrentSection(targetIndex);
            bool available = index >= 0;

            if (available)
            {
                if (CurrentSection == null || !CurrentSection.Active)
                {
                    targetIndex = lastIndex;
                    available   = false;
                    int dir = (index - targetIndex);
                    dir = (int)Mathf.Sign(dir);
                    Section testSection = null;
                    for (int i = 1; i < sections.Length; i++)
                    {
                        testSection = sections.GetLoop(targetIndex + (dir * i));
                        if (testSection != null && testSection.Active)
                        {
                            available   = true;
                            targetIndex = sections.GetIndexOf(testSection);
                            break;
                        }
                    }
                }
            }

            if (!available)
            {
                targetIndex = lastIndex;
            }

            SetCurrentSection(targetIndex);
            CurrentSection.SetCurrentButton(preButtonIndex);
        }
コード例 #2
0
 public void SwitchLayer(int layer, int buttonSelect = -1, int sectionIndex = 0)
 {
     currentLayer = layer;
     SetSection(sectionIndex);
     CurrentSection.SetCurrentButton(buttonSelect);
 }