Exemplo n.º 1
0
        public LegendEntryView InstantiateLegendEntry(Transform parent, Vector2 pivot)
        {
            LegendEntryView entry     = InstantiateWithPrefab(Resources.Load <LegendEntryView> ("prefabs/LegendEntryView"), parent);
            RectTransform   transform = entry.GetComponent <RectTransform> ();

            transform.pivot            = pivot;
            transform.anchorMin        = new Vector2(0, 0);
            transform.anchorMax        = new Vector2(0, 0);
            transform.anchoredPosition = Vector3.zero;

            return(entry);
        }
Exemplo n.º 2
0
        private void SetupLegendEntryView(LegendEntryView view, LegendEntry entry, int index)
        {
            RectTransform viewTransform = view.GetComponent <RectTransform>();

            viewTransform.sizeDelta        = new Vector2(ItemWidth, ItemHeight);
            viewTransform.pivot            = PivotFromAlignment(alignment);
            viewTransform.anchorMin        = AnchorsFromAlignment(alignment);
            viewTransform.anchorMax        = AnchorsFromAlignment(alignment);
            viewTransform.anchoredPosition = CalculateLegendEntryPosition(index);
            view.nameLabel.SetLabelText(entry.Title);
            view.nameLabel.SetLabelTextSize(TextSize);
            view.nameLabel.SetLabelColor(TextColor);
            view.iconImage.color  = entry.Color;
            view.iconImage.sprite = IconImage;
            view.IconSize         = IconSize;
            view.IconSpacing      = IconSpacing;
        }
Exemplo n.º 3
0
        private void UpdateLegendEntryViewInstances(int requiredCount)
        {
            int currentEntriesCount = legendEntryViews.Count;

            int missingEntiresCount = requiredCount - currentEntriesCount;

            while (missingEntiresCount > 0)
            {
                LegendEntryView entryView = InstantiateLegendEntryView();
                legendEntryViews.Add(entryView);
                missingEntiresCount--;
            }

            int redundantEntriesCount = currentEntriesCount - requiredCount;

            while (redundantEntriesCount > 0)
            {
                LegendEntryView target = legendEntryViews[legendEntryViews.Count - 1];
                DestroyDelayed(target.gameObject);
                legendEntryViews.Remove(target);
                redundantEntriesCount--;
            }
        }