4

Unity の新しい UI イメージ システムを使用して、プレーヤーにヘルスを実装しようとしていますが、うまくいきません。

    using UnityEngine.UI;

 if (health_value == 3) {
             GameObject.Find("health").GetComponent<Image>().color.a = 1;
             GameObject.Find("health1").GetComponent<Image>().color.a = 1;
             GameObject.Find("health2").GetComponent<Image>().color.a = 1;

         }

このエラーが発生しています。

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

5 に答える 5

0

または、

Image healthImage = GameObject.Find("health").GetComponent<Image>();
healthImage.color = Color.red;
于 2015-09-14T10:22:35.757 に答える