示例#1
0
    int SetImageProgress(ImageEx image, float value)
    {
        if (value <= 0)
        {
            if (image != null)
            {
                image.fillAmount = 0;
            }
            return(0);
        }

        int   num       = GetNumOfValue(value);
        float unitValue = Mathf.Clamp01((value % Unit) / Unit);

        if (unitValue == 0)
        {
            unitValue = 1;
        }

        //替换对应条数的图片
        if (m_spriteNames != null && num <= m_spriteNames.Length)
        {
            if (image != null)
            {
                image.Set(m_spriteNames[num - 1]);
            }
        }
        else if (m_sprites != null && num <= m_sprites.Length)
        {
            if (image != null)
            {
                image.overrideSprite = m_sprites[num - 1];
            }
        }

        //设置进度
        if (image != null)
        {
            image.fillAmount = unitValue;
        }
        EditorUtil.SetDirty(image);
        return(num);
    }