Setting the parent of a transform which resides in a Prefab Asset is disabled to prevent data corruption (GameObject: 'wall').
UnityEngine.Transform:SetParent(Transform)
weiqiang:weiqiangfangfa(GameObject, Vector3, Quaternion) (at Assets/Script/weiqiang.cs:25)
weiqiang:Awake() (at Assets/Script/weiqiang.cs:16)
翻译是说 设置位于预制资源中的转换的父级是禁用的,以防止数据损坏 游戏可以运行 就是会一直报这个错 是什么问题呢
同学你好,可以给老师看一下这个报错位置的代码吗,可以复制粘贴也可以截图? weiqiang 这个类。记得艾特一下老师。
好的 老师 游戏可以运行 也可以玩 就是会报这个错 那个 怎么@老师呢
public class weiqiang : MonoBehaviour
{
//0,墙,1,刚墙,2.草,3.水,4.老家,5.空气墙
public GameObject[] qiang;
private void Awake()
{
//老家
weiqiangfangfa(qiang[4],new Vector3(0,-8,0),Quaternion.identity);
//老家围墙
weiqiangfangfa(qiang[0],new Vector3(1,-8,0),Quaternion.identity);
weiqiangfangfa(qiang[0],new Vector3(-1,-8,0),Quaternion.identity);
for (int i=-1;i<2;i++)
{
weiqiangfangfa(qiang[0],new Vector3(i,-7,0),Quaternion.identity);
}
//外围墙
for (int i=-11;i<12;i++)
{
weiqiangfangfa(qiang[5],new Vector3(i,9,0),Quaternion.identity);
}
for (int i=-11;i<12;i++)
{
weiqiangfangfa(qiang[5],new Vector3(i,-9,0),Quaternion.identity);
}
for (int i=-9;i<10;i++)
{
weiqiangfangfa(qiang[5],new Vector3(-11,i,0),Quaternion.identity);
}
for (int i=-9;i<10;i++)
{
weiqiangfangfa(qiang[5],new Vector3(11,i,0),Quaternion.identity);
}
}
private void weiqiangfangfa(GameObject youxiwuti,Vector3 youxiweizhi,Quaternion youxixuanzhuan)
{
GameObject qiangfafang = Instantiate(youxiwuti,youxiweizhi,youxixuanzhuan);
youxiwuti.transform.SetParent(youxiwuti.transform);
}
}