C#统一问题。不允许使用主要构造函数主体

时间:2018-12-10 22:56:33

标签: unity3d

这是代码。当我尝试将脚本添加到Sprite时,出现“不允许主构造函数主体”错误。 在代码编辑器内部没有警报。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class weapon : MonoBehaviour {
    public GameObject dapo;
    public float offset;
    public Transform mira;
    private float tiempo;
    public float inicio;
    private void Update()
    {
        Vector3 difference = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
        float rotZ = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
        transform.rotation = Quaternion.Euler(0f, 0f, rotZ + offset);
        if (tiempo <= 0)
        {
            if (Input.GetMouseButtonDown(0))
            {
                Instantiate(dapo, mira.position, transform.rotation);
                tiempo = inicio;
            }
        }
        else
        {
            tiempo -= Time.deltaTime;
        }

    }

    }

0 个答案:

没有答案