How set a Color to ProgressLinear in DialogProgress?

+1 vote
asked May 2, 2016 in Issue by Joseph
I Have this code:

In the File DialogManager.cs:

     public static DialogProgress CreateProgressLinear()
        {
            DialogProgress dialog = PrefabManager.InstantiateGameObject(PrefabManager.ResourcePrefabs.dialogProgress, instance.transform).GetComponent<DialogProgress>();
            dialog.SetupIndicator(true);
            dialog.Initialize();
            return dialog;
        }

In the File DialogProgress.cs

public void Initialize(string bodyText, string titleText, ImageData icon, bool startStationaryAtZero = true)
        {
            m_TitleSection.SetTitle(titleText, icon);

            if (string.IsNullOrEmpty(bodyText))
            {
                m_BodyText.transform.parent.gameObject.SetActive(false);
            }
            else
            {
                m_BodyText.text = bodyText;
            }

            if (!startStationaryAtZero)
            {
                m_ProgressIndicator.StartIndeterminate();
            }
            else
            {
                m_ProgressIndicator.SetProgress(0f, false);
            }

/*Probé esto pero no sirve*/
            Color color = new Color (25,115,210,0);
            m_ProgressIndicator.SetColor (color);

/*********/
            Initialize();
        }

I want to set a Color to ProgressLinear Bar with this code, but i can´t

indicator.SetColor(color);

Help me please :).

1 Answer

0 votes
answered May 3, 2016 by admin (31,720 points)
 
Best answer

Hello!

I guess you have an issue because you're using a color with alpha at 0. So you don't see anything :)
Plus, colours must have values between 0 and 1, not 0 and 255. So divide everything by 255f.
Try to put new Color(25, 115, 210, 255) instead of new Color(25/255f, 115/255f, 210/255f, 0). This should work ;)

BUT! Instead of modifying the code from MaterialUI, you should do like this:
- Instead of calling DialogManager.ShowProgressLinear, you should do that:

DialogProgress dialogProgress = DialogManager.CreateProgressLinear();
dialogProgress.Initialize("bodyText", "titleText", MaterialIconHelper.GetRandomIcon(), false);
dialogProgress.progressIndicator.SetColor(new Color(25/255f, 115/255f, 210/255f, 1));
dialogProgress.ShowModal();

Have a great day ;)

~Yohan

Welcome to MaterialUI support! Ask us anything :)
...