Unity5学習の際の覚え書き。

Unityでの色の設定方法

1.Unityが用意したカラーネームを使う

Color.red

2.RGBAで設定

new Color(1f, 0.92f, 0.016f, 1f);

ランダムな色 Color randomColor = new Color( Random.value, Random.value, Random.value, 1.0f );

サンプルスクリプト

public class ChangeColorScript : MonoBehaviour {

    public GameObject myCube;

    // Use this for initialization
    void Start () {

        //gameObject取得 
        myCube = GameObject.Find("CubeName");

        //今の色コンソールに出力
        Debug.Log(myCube.renderer.material.color);

        //青色に変更
        myCube.renderer.material.color = Color.blue;

        //変更後の色コンソールに出力
        Debug.Log(myCube.renderer.material.color);
    }

    // Update is called once per frame
    void Update () {
    }
}

コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

Menu

【メニュー編集】
Wiki記法ガイド

リンク

ゲームバー大阪心斎橋

ゲームバー大阪梅田

ゲームバー大阪心斎橋

ダーツ&ダイニングバー大阪梅田

メニュー

Unity


スマホ操作

Unity - GameObject

Unity - 3DCG

メンバーのみ編集できます