예제 #1
0
        public void PopulatePort(Port port, string prefix)
        {
            bool gotColors = colors != null && colors.Count > 0;
            CircularIndex i = null;
            if (gotColors) i = new CircularIndex(colors.Count);

            int k = (names == null) ? 0 : names.Count;
            int l = (list == null) ? 0 : list.Count;
            int m = Math.Min(k, l);

            int j = 0;
            while (j < m) // named ones
            {
                list[j].PopulatePort(port, prefix + names[j]);
                if (gotColors)
                {
                    port[prefix + names[j]].Settings.Color = colors[i.Current];
                    i.Next();
                }
                j++;
            }

            string elsename = prefix + "All else";
            while (j < l) // and all others
            {
                list[j].PopulatePort(port, elsename);
                if (gotColors) port[elsename].Settings.Color = colors[i.Current];
                j++;
            }

            if (transformer != null)
            {
                port.Settings.Transformer = transformer;
            }
        }
    /// <summary>
    /// Function to make to control of movement and resizing operations also to change the selected element.
    /// Should be called in Update() of Monobehavior always that menu will be displayed
    /// </summary>
    public override void Update()
    {
        for (int i = 0; i < elementsArea.Count; i++)
        {
            elementsArea[i].Update();
        }

        if (isMoving)
        {
            return;
        }

        if (offsetPosition > 0)
        {
            Move(true);
            offsetPosition--;
            return;
        }
        else if (offsetPosition < 0)
        {
            Move(false);
            offsetPosition++;
            return;
        }

        float axis = GetPageScroll();

        if (axis > 0)
        {
            offsetPosition = elementsToShow;
            return;
        }
        else if (axis < 0)
        {
            offsetPosition = -elementsToShow;
            return;
        }

        base.Update();

        if (elementsToShow < menuIndex.Max())
        {
            if (GetAxis() > 0)
            {
                if (CircularIndex.UpDiff(topMenuIndex, menuIndex) >= elementsToShow)
                {
                    offsetPosition = 1;
                    menuIndex--;    // cancel menuIndex++ of base.Update
                    ChangeSelection();
                }
            }
            else if (GetAxis() < 0)
            {
                if (CircularIndex.CircularDiff(topMenuIndex, menuIndex) < 0)
                {
                    offsetPosition = -1;
                    menuIndex++;    // cancel menuIndex-- of base.Update
                    ChangeSelection();
                }
            }
        }
    }