一个类似与地平线中的车漆画板制作

效果图

 

  public void SetCarPaintColor()
    {
        //初始化行数列数
        int Hcount = 0;
        int Vconut = 0;
        Hcount = 17; //17列(由共同的线性特点的列数)
        Vconut = 9;  //9行
        for (int z = 0; z < Vconut; z++)
        {
            //第一列比较特殊首先生成第一列
            var MaintColor = Color.HSVToRGB(0, 0, ((z + 1) / 9.0f));
            //Img是一张图片
            var obj = Instantiate(Img);
            obj.GetComponent<Image>().color = MaintColor;
            obj.transform.parent = parentTransform;
        }
        //生成后面的所有
        for (int i = 0; i < Hcount; i++)
        {
            for (int j = 0; j < Vconut; j++)
            {
                float h = (i + 1) * (360 / Hcount);
                float v = (j + 1) * (100f / (Vconut % 2 == 0 ? Vconut / 2 : Vconut / 2 + 1));
                float s = 1;
                var MaintColor = Color.HSVToRGB(h / 360, 1, v / 100);
                if (j > (Vconut / 2))
                {
                    s = (1 * (Vconut-1 - j)) / (Vconut / 2f);
                    if (s <= 0.1f)
                        s = 0.1f;
                    MaintColor = Color.HSVToRGB(h / 360, s, 1);
                }
                var obj = Instantiate(Img);
                obj.GetComponent<Image>().color = MaintColor;
                obj.transform.parent = parentTransform;
            }
        }
    }

  

posted @ 2019-08-20 10:41  小木槌  阅读(152)  评论(0编辑  收藏  举报