我想更改实例化对象的父级,但是我已经挂断了某些东西。我收到错误,但我不确定它的确切含义:Assets / _Scripts / InstantiateSymbol.cs(29,73):错误CS0176:静态成员`UnityEngine.GameObject.FindGameObjectWithTag(string)'无法访问实例引用,使用类型名称来限定它
我在哪里?还在学习8 /
public GameObject symbolCharacter;
#region IPointerClickHandler implementation
public void OnPointerClick (PointerEventData eventData)
{
// Instantiate an object on Click
symbolCharacter = Instantiate(Resources.Load ("Prefabs/Symbols/SymbolImage1")) as GameObject;
symbolCharacter.transform.parent = transform.gameObject.FindGameObjectWithTag("MessagePanel");
}
#endregion
答案 0 :(得分:1)
啊,明白了! Captital' G' GameObject和我应该使用SetParent。
public GameObject symbolCharacter;
#region IPointerClickHandler implementation
public void OnPointerClick (PointerEventData eventData)
{
// Instantiate an object on Click
symbolCharacter = Instantiate(Resources.Load ("Prefabs/Symbols/SymbolImage1")) as GameObject;
symbolCharacter.transform.SetParent(GameObject.FindGameObjectWithTag("MessagePanel").transform);
}
#endregion