예제 #1
0
        private void RefreshContinued()
        {
            if (thisImage)
            {
                normalColor = thisImage.color;
            }

            if (highlightWhen != HighlightActive.Never)
            {
                highlightColor = rippleColor;

                HSBColor highlightColorHSB = HSBColor.FromColor(highlightColor);
                HSBColor normalColorHSB    = HSBColor.FromColor(normalColor);

                if (highlightColorHSB.s <= 0.05f)
                {
                    if (highlightColorHSB.b > 0.5f)
                    {
                        if (normalColorHSB.b > 0.9f)
                        {
                            highlightColorHSB.h = normalColorHSB.h;
                            highlightColorHSB.s = normalColorHSB.s - 0.1f;
                            highlightColorHSB.b = normalColorHSB.b + 0.2f;
                        }
                        else
                        {
                            highlightColorHSB.h = normalColorHSB.h;
                            highlightColorHSB.s = normalColorHSB.s;
                            highlightColorHSB.b = normalColorHSB.b + 0.2f;
                        }
                    }
                    else
                    {
                        highlightColorHSB.h = normalColorHSB.h;
                        highlightColorHSB.s = normalColorHSB.s;
                        highlightColorHSB.b = normalColorHSB.b - 0.15f;
                    }

                    highlightColor   = HSBColor.ToColor(highlightColorHSB);
                    highlightColor.a = normalColor.a;
                }
                else
                {
                    highlightColor.r = Anim.Linear(normalColor.r, highlightColor.r, 0.2f, 1f);
                    highlightColor.g = Anim.Linear(normalColor.g, highlightColor.g, 0.2f, 1f);
                    highlightColor.b = Anim.Linear(normalColor.b, highlightColor.b, 0.2f, 1f);
                    highlightColor.a = Anim.Linear(normalColor.a, highlightColor.a, 0.2f, 1f);
                }
            }

            animationDuration = 4 / rippleSpeed;
        }
        public void Setup()
        {
            contractedListColor = thisImage.color;
            normalColor         = expandedListColor;

            contractedNormalShadow = shadowConfig.shadowNormalSize;
            contractedHoverShadow  = shadowConfig.shadowActiveSize;

            if (textLine)
            {
                textLineAlpha = textLine.color.a;
            }

            listItemObjects = new GameObject[listItems.Length];

            for (int i = 0; i < listItems.Length; i++)
            {
                listItem = Instantiate(listItemPrefab) as GameObject;

                listItemObjects[i] = listItem;

                listItem.transform.SetParent(listLayer.transform);
                listItem.GetComponent <RectTransform>().localScale = new Vector3(1f, 1f, 1f);
                listItem.transform.localPosition = new Vector3(listItem.transform.localPosition.x, listItem.transform.localPosition.y, 0f);
                listItem.transform.localRotation = new Quaternion(0f, 0f, 0f, 0f);
                listItem.GetComponentInChildren <Text>().text = listItems[i];

                SelectionListItemConfig tempConfig = listItem.GetComponent <SelectionListItemConfig>();
                tempConfig.listId = i;

                RippleConfig tempRippleConfig = tempConfig.GetComponent <RippleConfig>();

                if (rippleEnabled)
                {
                    tempRippleConfig.autoSize         = false;
                    tempRippleConfig.rippleSize       = rippleSize;
                    tempRippleConfig.rippleSpeed      = rippleSpeed;
                    tempRippleConfig.rippleColor      = rippleColor;
                    tempRippleConfig.rippleStartAlpha = rippleStartAlpha;
                    tempRippleConfig.rippleEndAlpha   = rippleEndAlpha;
                    tempRippleConfig.moveTowardCenter = moveTowardCenter;
                    tempRippleConfig.toggleMask       = toggleMask;
                }
                else
                {
                    tempRippleConfig.autoSize         = false;
                    tempRippleConfig.rippleSize       = 0;
                    tempRippleConfig.rippleStartAlpha = 0f;
                    tempRippleConfig.rippleEndAlpha   = 0f;
                }

                if (highlightWhen == HighlightActive.Never)
                {
                    tempRippleConfig.highlightWhen = RippleConfig.HighlightActive.Never;
                }
                else if (highlightWhen == HighlightActive.Clicked)
                {
                    tempRippleConfig.highlightWhen = RippleConfig.HighlightActive.Clicked;
                }
                else if (highlightWhen == HighlightActive.Hovered)
                {
                    tempRippleConfig.highlightWhen = RippleConfig.HighlightActive.Hovered;
                }

                tempRippleConfig.Refresh();

                listItem.GetComponent <Image>().color = normalColor;

                listItem.GetComponent <SelectionListItemConfig>().Setup();
            }

            highlightColor = rippleColor;

            HSBColor highlightColorHSB = HSBColor.FromColor(highlightColor);


            if (highlightColorHSB.s <= 0.05f)
            {
                highlightColorHSB.s = 0f;
                highlightColorHSB.b = 0.9f;
            }
            else
            {
                highlightColorHSB.s = 0.1f;
                highlightColorHSB.b = 1f;
            }

            highlightColor = HSBColor.ToColor(highlightColorHSB);

            highlightColor.a = 1f;

            HSBColor normalColorHSB = HSBColor.FromColor(normalColor);

            if (normalColorHSB.b > 0.1f)
            {
                highlightColor *= normalColor;
            }
            else
            {
                highlightColor.a = 0.2f;
            }

            originalHeight = thisRect.sizeDelta.y;

            originalPos = thisRect.anchoredPosition.y;
            listLayer.SetActive(false);
            listCanvasGroup.interactable   = false;
            listCanvasGroup.blocksRaycasts = false;

            listCanvasGroup.alpha = 0f;

            listLayer.GetComponent <Image>().color = expandedListColor;
        }
예제 #3
0
        public void Refresh()
        {
            if (autoSize)
            {
                Rect tempRect = gameObject.GetComponent <RectTransform>().rect;

                if (tempRect.width > tempRect.height)
                {
                    rippleSize = Mathf.RoundToInt(tempRect.width);
                }
                else
                {
                    rippleSize = Mathf.RoundToInt(tempRect.height);
                }

                rippleSize = Mathf.RoundToInt(rippleSize * sizePercentage / 100f);
            }

            normalColor = thisImage.color;

            if (highlightWhen != HighlightActive.Never)
            {
                highlightColor = rippleColor;

                HSBColor highlightColorHSB = HSBColor.FromColor(highlightColor);
                HSBColor normalColorHSB    = HSBColor.FromColor(normalColor);

                if (highlightColorHSB.s <= 0.05f)
                {
                    if (highlightColorHSB.b > 0.5f)
                    {
                        if (normalColorHSB.b > 0.9f)
                        {
                            highlightColorHSB.h = normalColorHSB.h;
                            highlightColorHSB.s = normalColorHSB.s - 0.1f;
                            highlightColorHSB.b = normalColorHSB.b + 0.2f;
                        }
                        else
                        {
                            highlightColorHSB.h = normalColorHSB.h;
                            highlightColorHSB.s = normalColorHSB.s;
                            highlightColorHSB.b = normalColorHSB.b + 0.2f;
                        }
                    }
                    else
                    {
                        highlightColorHSB.h = normalColorHSB.h;
                        highlightColorHSB.s = normalColorHSB.s;
                        highlightColorHSB.b = normalColorHSB.b - 0.15f;
                    }

                    highlightColor   = HSBColor.ToColor(highlightColorHSB);
                    highlightColor.a = normalColor.a;
                }
                else
                {
                    highlightColor.r = Anim.Linear(normalColor.r, highlightColor.r, 0.2f, 1f);
                    highlightColor.g = Anim.Linear(normalColor.g, highlightColor.g, 0.2f, 1f);
                    highlightColor.b = Anim.Linear(normalColor.b, highlightColor.b, 0.2f, 1f);
                    highlightColor.a = Anim.Linear(normalColor.a, highlightColor.a, 0.2f, 1f);
                }
            }

            animationDuration = 4 / rippleSpeed;
        }
예제 #4
0
        public void Setup()
        {
            assignComponents();

            if (expanded)
            {
                var tmp = thisRect.sizeDelta;
                tmp.y = originalHeight;
                thisRect.sizeDelta = tmp;

                var tmp2 = thisRect.anchoredPosition;
                tmp2.y = originalPos;
                thisRect.anchoredPosition = tmp2;
                ContractList();
            }

            listLayer.GetComponent <RectTransform> ().anchoredPosition = Vector2.zero;

            selectedText.text = defaultText;
//			Debug.LogWarning ("LIST HEIGHT: "+listheight);
//			Debug.LogWarning ("LIST LAYER HEIGHT: "+listLayerHeight);

            currentSelection = -1;

            contractedListColor = thisImage.color;
            normalColor         = expandedListColor;


            if (shadowConfig != null)
            {
                contractedNormalShadow = shadowConfig.shadowNormalSize;
                contractedHoverShadow  = shadowConfig.shadowActiveSize;
            }


            if (textLine)
            {
                textLineAlpha = textLine.color.a;
            }

            listItemObjects = new GameObject[listItems.Length];


            // clear old
            foreach (Transform r in listLayer.transform)
            {
                Destroy(r.gameObject);
            }

            for (int i = 0; i < listItems.Length; i++)
            {
                listItem = Instantiate(listItemPrefab) as GameObject;

                listItemObjects[i] = listItem;

                listItem.transform.SetParent(listLayer.transform);
                listItem.GetComponent <RectTransform>().localScale = new Vector3(1f, 1f, 1f);
                listItem.transform.localPosition = new Vector3(listItem.transform.localPosition.x, listItem.transform.localPosition.y, 0f);
                listItem.transform.localRotation = new Quaternion(0f, 0f, 0f, 0f);
                listItem.GetComponentInChildren <Text>().text = listItems[i];

                SelectionListItemConfig tempConfig = listItem.GetComponent <SelectionListItemConfig>();
                tempConfig.listId = i;

                RippleConfig tempRippleConfig = tempConfig.GetComponent <RippleConfig>();

                if (rippleEnabled)
                {
                    tempRippleConfig.autoSize         = false;
                    tempRippleConfig.rippleSize       = rippleSize;
                    tempRippleConfig.rippleSpeed      = rippleSpeed;
                    tempRippleConfig.rippleColor      = rippleColor;
                    tempRippleConfig.rippleStartAlpha = rippleStartAlpha;
                    tempRippleConfig.rippleEndAlpha   = rippleEndAlpha;
                    tempRippleConfig.moveTowardCenter = moveTowardCenter;
                    tempRippleConfig.toggleMask       = toggleMask;
                }
                else
                {
                    tempRippleConfig.autoSize         = false;
                    tempRippleConfig.rippleSize       = 0;
                    tempRippleConfig.rippleStartAlpha = 0f;
                    tempRippleConfig.rippleEndAlpha   = 0f;
                }

                if (highlightWhen == HighlightActive.Never)
                {
                    tempRippleConfig.highlightWhen = RippleConfig.HighlightActive.Never;
                }
                else if (highlightWhen == HighlightActive.Clicked)
                {
                    tempRippleConfig.highlightWhen = RippleConfig.HighlightActive.Clicked;
                }
                else if (highlightWhen == HighlightActive.Hovered)
                {
                    tempRippleConfig.highlightWhen = RippleConfig.HighlightActive.Hovered;
                }

                tempRippleConfig.Refresh();

                listItem.GetComponent <Image>().color = normalColor;

                listItem.GetComponent <SelectionListItemConfig>().Setup();
            }

            highlightColor = rippleColor;

            HSBColor highlightColorHSB = HSBColor.FromColor(highlightColor);


            if (highlightColorHSB.s <= 0.05f)
            {
                highlightColorHSB.s = 0f;
                highlightColorHSB.b = 0.9f;
            }
            else
            {
                highlightColorHSB.s = 0.1f;
                highlightColorHSB.b = 1f;
            }

            highlightColor = HSBColor.ToColor(highlightColorHSB);

            highlightColor.a = 1f;

            HSBColor normalColorHSB = HSBColor.FromColor(normalColor);

            if (normalColorHSB.b > 0.1f)
            {
                highlightColor *= normalColor;
            }
            else
            {
                highlightColor.a = 0.2f;
            }


            originalHeight = thisRect.sizeDelta.y;


            originalPos = thisRect.anchoredPosition.y;
            listLayer.SetActive(false);
            listCanvasGroup.interactable   = false;
            listCanvasGroup.blocksRaycasts = false;

            listCanvasGroup.alpha = 0f;

            listLayer.GetComponent <Image>().color = expandedListColor;
        }