Help us understand the problem. What is going on with this article?

【Unity】Scriptからambient color変更

More than 5 years have passed since last update.

Scriptからambient colorを変更する方法(Unity var5.1)
例:ChangeColorを呼ぶたびにランダムでambient colorを変える場合

sample.cs
void ChangeColor(){
     Color colorGreen=new Color(134f,244f,171f,255f);
     Color colorBlue=new Color(134f,140f,244f,255f);
     Color colorRed=new  Color(244f,134f,182f,255f);
     Color colorOrange=new Color(244f,182f,134f,255f);
     Color[] colorList={colorGreen,colorBlue,colorRed,colorOrange};
     int randamColor=Random.Range(0,colorList.Length);
     float sum = colorList[randamColor].r
                       + colorList[randamColor].g 
                      + colorList[randamColor].b;
     float reciprocal = 1/sum;
        colorList[randamColor] = colorList[randamColor]*reciprocal;
        RenderSettings.ambientSkyColor=colorList[randamColor];
    }

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away