void Start()
 {
     thisImage        = gameObject.GetComponent <Image>();
     thisRippleConfig = gameObject.GetComponent <RippleConfig>();
     Color.TryParseHexString("#0A0A0AFF", out activeColor);
     Color.TryParseHexString("#212121FF", out normalColor);
 }
Ejemplo n.º 2
0
 void OnEnable()
 {
     //	Set references
     toggle = gameObject.GetComponent <Toggle>();
     switchRectTransform = switchImage.GetComponent <RectTransform>();
     checkBoxToggler     = text.GetComponent <CheckBoxToggler>();
     rippleConfig        = gameObject.GetComponent <RippleConfig>();
 }
Ejemplo n.º 3
0
		void OnEnable()
		{
			//	Set references
			toggle = gameObject.GetComponent<Toggle>();
			switchRectTransform = switchImage.GetComponent<RectTransform>();
			checkBoxToggler = text.GetComponent<CheckBoxToggler>();
			rippleConfig = gameObject.GetComponent<RippleConfig>();
		}
Ejemplo n.º 4
0
 void OnEnable()
 {
     //	Set references
     toggle             = gameObject.GetComponent <Toggle>();
     checkRectTransform = checkImage.GetComponent <RectTransform>();
     frameCanvasGroup   = frameImage.GetComponent <CanvasGroup>();
     checkBoxToggler    = text.GetComponent <CheckBoxToggler>();
     rippleConfig       = gameObject.GetComponent <RippleConfig>();
 }
Ejemplo n.º 5
0
 void OnEnable()
 {
     //	Set references
     toggle = gameObject.GetComponent <Toggle>();
     //	Debug.LogWarning ("Setting TOGGLE ref: "+(toggle==null?"NULL":"NOT NULL"));
     switchRectTransform = switchImage.GetComponent <RectTransform>();
     checkBoxToggler     = text.GetComponent <CheckBoxToggler>();
     rippleConfig        = gameObject.GetComponent <RippleConfig>();
 }
Ejemplo n.º 6
0
		void OnEnable()
		{
			//	Set references
			toggle = gameObject.GetComponent<Toggle>();
			checkRectTransform = checkImage.GetComponent<RectTransform>();
			frameCanvasGroup = frameImage.GetComponent<CanvasGroup>();
			checkBoxToggler = text.GetComponent<CheckBoxToggler>();
			rippleConfig = gameObject.GetComponent<RippleConfig>();
		}
Ejemplo n.º 7
0
		public void OnEnable ()
		{
			//	Set references
			toggle = gameObject.GetComponent<Toggle>();
			toggleGroup = gameObject.GetComponent<Transform>().parent.parent.GetComponent<ToggleGroup>();
			dotRectTransform = dotImage.GetComponent<RectTransform>();
			checkBoxToggler = text.GetComponent<CheckBoxToggler>();
			rippleConfig = gameObject.GetComponent<RippleConfig>();
			toggle.group = toggleGroup;
		}
Ejemplo n.º 8
0
 public void OnEnable()
 {
     //	Set references
     toggle           = gameObject.GetComponent <Toggle>();
     toggleGroup      = gameObject.GetComponent <Transform>().parent.parent.GetComponent <ToggleGroup>();
     dotRectTransform = dotImage.GetComponent <RectTransform>();
     checkBoxToggler  = text.GetComponent <CheckBoxToggler>();
     rippleConfig     = gameObject.GetComponent <RippleConfig>();
     toggle.group     = toggleGroup;
 }
Ejemplo n.º 9
0
 void OnEnable()
 {
     //	Set references
     toggle             = gameObject.GetComponent <Toggle>();
     checkRectTransform = checkImage.GetComponent <RectTransform>();
     frameCanvasGroup   = frameImage.GetComponent <CanvasGroup>();
     if (text == null)
     {
         text = gameObject.transform.parent.Find("Text").GetComponent <Text>();
     }
     checkBoxToggler = text.GetComponent <CheckBoxToggler>();
     rippleConfig    = gameObject.GetComponent <RippleConfig>();
 }
Ejemplo n.º 10
0
        public void ContractList()
        {
            expanded     = false;
            icon.enabled = true;

            if (hasShadows)
            {
                shadowConfig.isEnabled = true;
                shadowConfig.SetShadows(contractedShadowLevel);
            }

            currentColor = thisImage.color;

            if (!rippleConfig)
            {
                rippleConfig = gameObject.GetComponent <RippleConfig> ();
            }
            if (!thisButton)
            {
                thisButton = gameObject.GetComponent <Button> ();
            }

            if (rippleConfig)
            {
                rippleConfig.enabled = true;
            }
            thisButton.interactable = true;

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

            listCanvasGroup.interactable   = false;
            listCanvasGroup.blocksRaycasts = false;
            scrollbar.enabled = false;
            scrollbarCanvasGroup.interactable   = false;
            scrollbarCanvasGroup.blocksRaycasts = false;

            cancelLayer.enabled = false;

            listheight      = thisRect.sizeDelta.y;
            listCanvasAlpha = listCanvasGroup.alpha;

            animStartTime = Time.realtimeSinceStartup;
            state         = 2;
        }
        public void ExpandList()
        {
            originalPos = thisRect.anchoredPosition.y;

            if (gameObject.GetComponent <ShadowConfig>())
            {
                hasShadows = true;
                if (!shadowConfig)
                {
                    shadowConfig = gameObject.GetComponent <ShadowConfig>();
                }
            }
            else
            {
                hasShadows = false;
            }

            contractedShadowLevel = shadowConfig.shadowNormalSize;

            if (!rippleConfig)
            {
                rippleConfig = gameObject.GetComponent <RippleConfig> ();
            }
            if (!thisButton)
            {
                thisButton = gameObject.GetComponent <Button> ();
            }

            shadowConfig.shadowNormalSize = expandedListShadowLevel;
            shadowConfig.shadowActiveSize = expandedListShadowLevel;

            rippleConfig.enabled    = false;
            thisButton.interactable = false;

            icon.enabled         = false;
            selectedText.enabled = false;

            currentColor = thisImage.color;

            if (autoMaxItemHeight)
            {
                float tempFloat = (Screen.height / 100f * percentageOfScreenHeight / 36f);


                if (tempFloat >= listItems.Length)
                {
                    listheight = (listItems.Length * 36f) + 16f;
                }
                else
                {
                    listheight        = (tempFloat * 36f) - 8f;
                    scrollbarEnabled  = true;
                    scrollbar.enabled = true;
                    scrollbarCanvasGroup.interactable   = true;
                    scrollbarCanvasGroup.blocksRaycasts = true;
                }
            }
            else if (manualMaxItemHeight > 0)
            {
                listheight        = (manualMaxItemHeight * 36f) - 8f;
                scrollbarEnabled  = true;
                scrollbar.enabled = true;
                scrollbarCanvasGroup.interactable   = true;
                scrollbarCanvasGroup.blocksRaycasts = true;
            }
            else
            {
                listheight = (listItems.Length * 36f) + 16f;
            }

            listLayerHeight = (listItems.Length * 36f) + 16f;

            if (expandDirection == PopDirection.Popup)
            {
                expandedPos = originalPos + (listheight / 2f) - 24f;
            }
            else if (expandDirection == PopDirection.Popdown)
            {
                expandedPos = originalPos - (listheight / 2f) + 24f;
            }
            else
            {
                expandedPos = originalPos;
            }

            listLayer.SetActive(true);
            listCanvasGroup.interactable   = true;
            listCanvasGroup.blocksRaycasts = true;
            cancelLayer.enabled            = true;
            icon.enabled         = false;
            selectedText.enabled = true;

            listCanvasAlpha = listCanvasGroup.alpha;

            animStartTime = Time.realtimeSinceStartup;
            state         = 1;
        }
        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;
        }
Ejemplo n.º 13
0
        public void ExpandList()
        {
            originalPos = thisRect.anchoredPosition.y;

            if (gameObject.GetComponent<ShadowConfig>())
            {
                hasShadows = true;
                if (!shadowConfig)
                    shadowConfig = gameObject.GetComponent<ShadowConfig>();
            }
            else
            {
                hasShadows = false;
            }

            contractedShadowLevel = shadowConfig.shadowNormalSize;

            if (!rippleConfig)
                rippleConfig = gameObject.GetComponent<RippleConfig> ();
            if (!thisButton)
                thisButton = gameObject.GetComponent<Button> ();

            shadowConfig.shadowNormalSize = expandedListShadowLevel;
            shadowConfig.shadowActiveSize = expandedListShadowLevel;

            rippleConfig.enabled = false;
            thisButton.interactable = false;

            icon.enabled = false;
            selectedText.enabled = false;

            currentColor = thisImage.color;

            if (autoMaxItemHeight)
            {
                float tempFloat = (Screen.height / 100f * percentageOfScreenHeight / 36f);

                if (tempFloat >= listItems.Length)
                {
                    listheight = (listItems.Length * 36f) + 16f;
                }
                else
                {
                    listheight = (tempFloat * 36f) - 8f;
                    scrollbarEnabled = true;
                    scrollbar.enabled = true;
                    scrollbarCanvasGroup.interactable = true;
                    scrollbarCanvasGroup.blocksRaycasts = true;
                }
            }
            else if (manualMaxItemHeight > 0)
            {

                listheight = (manualMaxItemHeight * 36f) - 8f;
                scrollbarEnabled = true;
                scrollbar.enabled = true;
                scrollbarCanvasGroup.interactable = true;
                scrollbarCanvasGroup.blocksRaycasts = true;
            }
            else
            {
                listheight = (listItems.Length * 36f) + 16f;
            }

            listLayerHeight = (listItems.Length * 36f) + 16f;

            if (expandDirection == PopDirection.Popup)
                expandedPos = originalPos + (listheight / 2f) - 24f;
            else if (expandDirection == PopDirection.Popdown)
                expandedPos = originalPos - (listheight / 2f) + 24f;
            else
                expandedPos = originalPos;

            listLayer.SetActive (true);
            listCanvasGroup.interactable = true;
            listCanvasGroup.blocksRaycasts = true;
            cancelLayer.enabled = true;
            icon.enabled = false;
            selectedText.enabled = true;

            listCanvasAlpha = listCanvasGroup.alpha;

            animStartTime = Time.realtimeSinceStartup;
            state = 1;
        }
Ejemplo n.º 14
0
        public void ExpandList()
        {
            expanded    = true;
            originalPos = thisRect.anchoredPosition.y;

            if (gameObject.GetComponent <ShadowConfig>())
            {
                hasShadows = true;
                if (!shadowConfig)
                {
                    shadowConfig = gameObject.GetComponent <ShadowConfig>();
                }
            }
            else
            {
                hasShadows = false;
            }

            if (shadowConfig != null)
            {
                contractedShadowLevel = shadowConfig.shadowNormalSize;
            }


            if (!rippleConfig)
            {
                rippleConfig = gameObject.GetComponent <RippleConfig> ();
            }
            if (!thisButton)
            {
                thisButton = gameObject.GetComponent <Button> ();
            }

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

            if (rippleConfig)
            {
                rippleConfig.enabled = false;
            }
            thisButton.interactable = false;

            icon.enabled         = false;
            selectedText.enabled = false;

            currentColor = thisImage.color;

            if (autoMaxItemHeight)
            {
                //var scale = Screen.dpi/82f;
                var canvasScale = AppScript.getSharedInstance().scaleFactorRefCanvas.scaleFactor;

                /*Debug.LogWarning ("Screen height: "+Screen.height);
                 * Debug.LogWarning ("DPI: "+Screen.dpi);
                 * Debug.LogWarning ("DPI scale: "+scale);
                 * Debug.LogWarning ("Canvas scale: "+canvasScale);
                 * Debug.LogWarning ("Item height: "+itemHeight);*/

                float tempFloat = Screen.height / canvasScale / 100f * percentageOfScreenHeight / itemHeight;
                //Debug.LogWarning ("Temp float: "+tempFloat);

                if (tempFloat >= listItems.Length)
                {
                    listheight = (listItems.Length * itemHeight) + 16f;
                }
                else
                {
                    listheight        = (tempFloat * itemHeight) - 8f;
                    scrollbarEnabled  = true;
                    scrollbar.enabled = true;
                    scrollbarCanvasGroup.interactable   = true;
                    scrollbarCanvasGroup.blocksRaycasts = true;
                }

                //Debug.LogWarning ("List height: "+listheight);
            }
            else if (manualMaxItemHeight > 0)
            {
                listheight        = (manualMaxItemHeight * itemHeight) - 8f;
                scrollbarEnabled  = true;
                scrollbar.enabled = true;
                scrollbarCanvasGroup.interactable   = true;
                scrollbarCanvasGroup.blocksRaycasts = true;
            }
            else
            {
                listheight = (listItems.Length * itemHeight) + 16f;
            }

            listLayerHeight = (listItems.Length * itemHeight) + 16f;

            if (expandDirection == PopDirection.Popup)
            {
                expandedPos = originalPos + (listheight / 2f) - 24f;
            }
            else if (expandDirection == PopDirection.Popdown)
            {
                expandedPos = originalPos - (listheight / 2f) + 24f;
            }
            else
            {
                expandedPos = originalPos;
            }

            listLayer.SetActive(true);
            listCanvasGroup.interactable   = true;
            listCanvasGroup.blocksRaycasts = true;
            cancelLayer.enabled            = true;
            icon.enabled         = false;
            selectedText.enabled = true;

            listCanvasAlpha = listCanvasGroup.alpha;

            animStartTime = Time.realtimeSinceStartup;
            state         = 1;
        }
Ejemplo n.º 15
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;
        }