找回密码
 立即注册
查看: 162|回复: 2

[笔记] unity大佬请帮我看看代码有什么问题?可以运行的,可是 ...

[复制链接]
发表于 2023-2-11 12:19 | 显示全部楼层 |阅读模式
using System.Collections;
using System.Collections.Generic;
using UnityEngine.EventSystems;
using UnityEngine;
using Unity.VisualScripting;
using System;

public class Playcontrol : MonoBehaviour, IPointerClickHandler
{
    public float forcenub;
    Rigidbody rb;

    public void OnPointerClick(PointerEventData eventData)
    {
        switch (eventData.button)
        {
            case PointerEventData.InputButton.Right:
                Update();
                {
                    float hInput = 0;
                    hInput = Input.GetAxis("Horizontal");
                    float vInput = 0;
                    vInput = Input.GetAxis("Vertical");
                    rb.AddForce(new Vector3(hInput, 0, vInput).normalized * forcenub);

                }
            break;
        }

        // Start is called before the first frame update
        void Start()
        {
            rb = GetComponent();

        }

        // Update is called once per frame

    }

    private void Update()
    {
        throw new NotImplementedException();
    }
}
发表于 2023-2-11 12:26 | 显示全部楼层
update是生命周期函数,每帧都会执行的,里面有抛出异常的代码,相当于每帧抛出一次
发表于 2023-2-11 12:32 | 显示全部楼层
你还没实现Update方法呢,那里面一直在throw exception
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-5-2 01:24 , Processed in 0.242789 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表