此代码有什么问题?获得意外的符号覆盖

时间:2019-01-06 15:47:33

标签: unity3d

当尝试编译以下代码时,编译器会说以下内容:

意外的符号覆盖

有人可以帮助诊断问题吗?该代码似乎应该可以根据我在其他网站和论坛上的研究得出结论,但是我不知道从哪里开始尝试解决该问题。

UnityEngine;
using System.Collections;

public class Reload : StateMachineBehaviour {

    public float reloadTime = 0.7f;
    bool hasReloaded = false

     // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
        hasReloaded = false;


    }

    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
        if (hasReloaded) return;

        if(stateInfo.normalizedTime >= reloadTime)
        {
            animator.GetComponent<pyssy>().Reload();
            hasReloaded = true;
        }
    }

    // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
        hasReloaded = false;

    }

    // OnStateMove is called right after Animator.OnAnimatorMove(). Code that processes and affects root motion should be implemented here
    //override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //
    //}

    // OnStateIK is called right after Animator.OnAnimatorIK(). Code that sets up animation IK (inverse kinematics) should be implemented here.
    //override public void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //
    //}
}

1 个答案:

答案 0 :(得分:2)

在检查您的代码后,似乎由于至少一个语法错误而无法编译。

我发现您在这里缺少分号:

bool hasReloaded = false

接下来,以下if块对名为GetComponent的类执行pyssy

我不确定这是否是错字。但这对我来说似乎不是一个有用的类名称。

尽管如此,这更多的只是一个注释。 缺少分号可能是与您当前的Unexpect symbol override错误有关的问题。