簡體   English   中英

unity Assets\\script\\Produce.cs(10,20): 錯誤 CS1002: ; 預期分辨率

[英]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): 錯誤 CS1002: ; 預期 Assets\\script\\Produce.cs(10,23): 錯誤 CS1003: 語法錯誤, ',' 預期

我收到此錯誤 解決方法是什么?

您必須定義triggersquare ,然后從編輯器(拖放)分配游戲對象。

[SerializeField] private GameObject square = null;

var trigger = square.AddComponent<Trigger>();

如果您不使用它,也刪除函數Update()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM