LoginSignup
7
7

More than 5 years have passed since last update.

Unity C# で GUIパーツのα値を設定する方法

Posted at

Unity C# で GUIパーツのα値を以下のようにして設定しようとするとおこられます。
(Javascriptだと問題ないのですが・・・)

GUI.color.a = 0.5f;

結果:コンパイルエラー

error CS1612: Cannot modify a value type return value of `UnityEngine.GUI.color'. Consider storing the value in a temporary variable

解決するには以下のように書きます。

GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 0.5f);
7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7