前提・実現したいこと
ボタン1を押したらボタン1は緑色、ボタン2は白色に。
ボタン2を押したらボタン2は緑色、ボタン1は白色に。なるようにしたいです。
発生している問題・エラーメッセージ
エラーメッセージ
該当のソースコード
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class MyButton : MonoBehaviour { public void ButtonClick() { switch (transform.name) { case "Button1": GetComponent<Image>().color = Color.green; Debug.Log("3.1415"); break; case "Button2": GetComponent<Image>().color = Color.green; Debug.Log("2.7181"); break; default: break; } } // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } }
試したこと
調べてみましたが、よくわかりませんでした。
補足情報(FW/ツールのバージョンなど)
最近始めたばかりの、初心者です。
調べた、参考にした記事を貼っていただけますか。
その記事のどの部分が分からなかったかを追記して頂くと回答しやすいです。
あなたの回答
tips
プレビュー