[英]unity Assets\script\Produce.cs(10,20): error CS1002: ; expected resolution
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
trigger Square.AddComponent<Trigger>();
}
// Update is called once per frame
void Update()
{
}
public void newObject(string Square)
{
GameObject Instance = Instantiate (Square, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
Instance.name = Square;
}
}
Assets\\script\\Produce.cs(10,24): error CS1002: ; Assets\\script\\Produce.cs(10,24): 错误 CS1002: ; expected Assets\\script\\Produce.cs(10,23): error CS1003: Syntax error, ',' expected
预期 Assets\\script\\Produce.cs(10,23): 错误 CS1003: 语法错误, ',' 预期
I get this error What is the workaround?我收到此错误 解决方法是什么?
You have to define trigger
and square
and then assign the gameObject from editor (drag & drop).您必须定义
trigger
和square
,然后从编辑器(拖放)分配游戏对象。
[SerializeField] private GameObject square = null;
var trigger = square.AddComponent<Trigger>();
Also remove function Update()
if you are not using it.如果您不使用它,也删除函数
Update()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.