导致错误的代码,
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.UIElements;
public class OyunKontrol : MonoBehaviour
{
public GameObject secilmisText;
public GameObject devretPanel;
public GameObject yaziTuraText;
public int sonuc = 1;
public int sira;
public string yaziTuraCikti = "Tura";
public string secilmisName;
public Color player1Color;
public Color player2Color;
public Color player3Color;
public Color player4Color;
void Start()
{
sira = 1;
print("Saldırmak veya almak istediğiniz şehri seçiniz...");
secilmisName = null;
** player1Color = GameObject.Find("Player1").GetComponent<Image>().color;
player2Color = GameObject.Find("Player2").GetComponent<Image>().color;
player3Color = GameObject.Find("Player3").GetComponent<Image>().color;
player4Color = GameObject.Find("Player4").GetComponent<Image>().color;**
}
粗体代码是错误根源的部分。
我该如何解决?
我尝试删除并重写代码但错误没有解决
这是因为Image类在
UIElement
引用和Unity UI
中都存在,无法区分这个类属于哪一个。根据你的代码,这个类应该属于Unity UI,所以最好用UI Element去掉。
using UnityEngine.UIElements;