Esempio n. 1
0
    public MyGUI3_1.HSBColor ColorToHSV(Color color)
    {
        MyGUI3_1.HSBColor hsbColor = new MyGUI3_1.HSBColor(0.0f, 0.0f, 0.0f, (float)color.a);
        float             r        = (float)color.r;
        float             g        = (float)color.g;
        float             b        = (float)color.b;
        float             num1     = Mathf.Max(r, Mathf.Max(g, b));

        if ((double)num1 <= 0.0)
        {
            return(hsbColor);
        }
        float num2 = Mathf.Min(r, Mathf.Min(g, b));
        float num3 = num1 - num2;

        if ((double)num1 > (double)num2)
        {
            hsbColor.h = (double)g != (double)num1 ? ((double)b != (double)num1 ? ((double)b <= (double)g ? (float)(((double)g - (double)b) / (double)num3 * 60.0) : (float)(((double)g - (double)b) / (double)num3 * 60.0 + 360.0)) : (float)(((double)r - (double)g) / (double)num3 * 60.0 + 240.0)) : (float)(((double)b - (double)r) / (double)num3 * 60.0 + 120.0);
            if ((double)hsbColor.h < 0.0)
            {
                hsbColor.h += 360f;
            }
        }
        else
        {
            hsbColor.h = 0.0f;
        }
        hsbColor.h *= 1f / 360f;
        hsbColor.s  = (float)((double)num3 / (double)num1 * 1.0);
        hsbColor.b  = num1;
        return(hsbColor);
    }
Esempio n. 2
0
    public Color HSVToColor(MyGUI3_1.HSBColor hsbColor)
    {
        float num1 = hsbColor.b;
        float num2 = hsbColor.b;
        float num3 = hsbColor.b;

        if ((double)hsbColor.s != 0.0)
        {
            float b    = hsbColor.b;
            float num4 = hsbColor.b * hsbColor.s;
            float num5 = hsbColor.b - num4;
            float num6 = hsbColor.h * 360f;
            if ((double)num6 < 60.0)
            {
                num1 = b;
                num2 = (float)((double)num6 * (double)num4 / 60.0) + num5;
                num3 = num5;
            }
            else if ((double)num6 < 120.0)
            {
                num1 = (float)(-((double)num6 - 120.0) * (double)num4 / 60.0) + num5;
                num2 = b;
                num3 = num5;
            }
            else if ((double)num6 < 180.0)
            {
                num1 = num5;
                num2 = b;
                num3 = (float)(((double)num6 - 120.0) * (double)num4 / 60.0) + num5;
            }
            else if ((double)num6 < 240.0)
            {
                num1 = num5;
                num2 = (float)(-((double)num6 - 240.0) * (double)num4 / 60.0) + num5;
                num3 = b;
            }
            else if ((double)num6 < 300.0)
            {
                num1 = (float)(((double)num6 - 240.0) * (double)num4 / 60.0) + num5;
                num2 = num5;
                num3 = b;
            }
            else if ((double)num6 <= 360.0)
            {
                num1 = b;
                num2 = num5;
                num3 = (float)(-((double)num6 - 360.0) * (double)num4 / 60.0) + num5;
            }
            else
            {
                num1 = 0.0f;
                num2 = 0.0f;
                num3 = 0.0f;
            }
        }
        return(new Color(Mathf.Clamp01(num1), Mathf.Clamp01(num2), Mathf.Clamp01(num3), hsbColor.a));
    }
Esempio n. 3
0
    private void ChangeColor()
    {
        Color color1 = this.Hue(this.colorHUE / (float)byte.MaxValue);

        foreach (Renderer componentsInChild in (Renderer[])this.currentGo.GetComponentsInChildren <Renderer>())
        {
            Material material = componentsInChild.get_material();
            if (!Object.op_Equality((Object)material, (Object)null))
            {
                if (material.HasProperty("_TintColor"))
                {
                    Color             color2 = material.GetColor("_TintColor");
                    MyGUI3_1.HSBColor hsv    = this.ColorToHSV(color2);
                    hsv.h    = this.colorHUE / 360f;
                    color1   = this.HSVToColor(hsv);
                    color1.a = color2.a;
                    material.SetColor("_TintColor", color1);
                }
                if (material.HasProperty("_CoreColor"))
                {
                    Color             color2 = material.GetColor("_CoreColor");
                    MyGUI3_1.HSBColor hsv    = this.ColorToHSV(color2);
                    hsv.h    = this.colorHUE / 360f;
                    color1   = this.HSVToColor(hsv);
                    color1.a = color2.a;
                    material.SetColor("_CoreColor", color1);
                }
            }
        }
        foreach (Projector componentsInChild in (Projector[])this.currentGo.GetComponentsInChildren <Projector>())
        {
            Material material = componentsInChild.get_material();
            if (!Object.op_Equality((Object)material, (Object)null) && material.HasProperty("_TintColor"))
            {
                Color             color2 = material.GetColor("_TintColor");
                MyGUI3_1.HSBColor hsv    = this.ColorToHSV(color2);
                hsv.h    = this.colorHUE / 360f;
                color1   = this.HSVToColor(hsv);
                color1.a = color2.a;
                componentsInChild.get_material().SetColor("_TintColor", color1);
            }
        }
        Light componentInChildren = (Light)this.currentGo.GetComponentInChildren <Light>();

        if (!Object.op_Inequality((Object)componentInChildren, (Object)null))
        {
            return;
        }
        componentInChildren.set_color(color1);
    }