Esempio n. 1
0
        protected void Start()
        {
            if (this.bar == null)
            {
                this.bar = this.GetComponent <UIStepBar>();
            }

            if (this.bar == null)
            {
                this.enabled = false;
                return;
            }

            this.StartCoroutine("FillProgress");
        }
Esempio n. 2
0
        protected void DrawOverrideFillTable()
        {
            UIStepBar bar = base.target as UIStepBar;
            List <UIStepBar.StepFillInfo> list = bar.GetOverrideFillList();

            EditorGUILayout.LabelField("Override Fill Amount");
            EditorGUI.indentLevel = (EditorGUI.indentLevel + 1);

            for (int i = 1; i <= this.m_StepsCount.intValue; i++)
            {
                // Check if we have override info for the step
                int overrideIndex = list.FindIndex(x => x.index == i);

                // If we have info
                if (overrideIndex >= 0)
                {
                    // Get the info
                    UIStepBar.StepFillInfo info = list[overrideIndex];

                    EditorGUI.BeginChangeCheck();
                    float newAmount = EditorGUILayout.FloatField("Step #" + i.ToString(), info.amount);
                    if (EditorGUI.EndChangeCheck())
                    {
                        UIStepBar.StepFillInfo newInfo = new UIStepBar.StepFillInfo();
                        newInfo.amount      = newAmount;
                        newInfo.index       = i;
                        list[overrideIndex] = newInfo;

                        // Validate the override list to remove the zero amount info
                        if (newAmount == 0f)
                        {
                            bar.ValidateOverrideFillList();
                        }

                        // Update the fill image fillAmount
                        bar.UpdateFillImage();

                        // Set the object as dirty to be saved on the disk
                        EditorUtility.SetDirty(bar);
                    }
                }
                else                 // We dont have override info for the current step
                {
                    EditorGUI.BeginChangeCheck();
                    float newAmount = EditorGUILayout.FloatField("Step #" + i.ToString(), bar.GetStepFillAmount(i));
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (newAmount > 0f)
                        {
                            UIStepBar.StepFillInfo newInfo = new UIStepBar.StepFillInfo();
                            newInfo.amount = newAmount;
                            newInfo.index  = i;
                            list.Add(newInfo);

                            // Update the fill image fillAmount
                            bar.UpdateFillImage();

                            // Set the object as dirty to be saved on the disk
                            EditorUtility.SetDirty(bar);
                        }
                    }
                }
            }

            EditorGUI.indentLevel = (EditorGUI.indentLevel - 1);
        }