微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我该如何解决:无法将lambda表达式转换为类型'bool',因为它不是委托类型

如何解决我该如何解决:无法将lambda表达式转换为类型'bool',因为它不是委托类型

我一直在向游戏中添加一个已保存的Highscore系统,但出现此错误

无法将lambda表达式转换为类型'bool',因为它不是委托类型

这是我的剧本

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

public class Highscoredisplay : MonoBehavIoUr
{
    public Text display;
    public static int score;
    private int Highscore;
    private int Latescore;

    void Start()
    {
        Highscore = PlayerPrefs.GetInt("Highscore",0);
    }

    // Update is called once per frame
    void Update()
    {
        display.text = (score.ToString());

        // This is the error
        if (score => Highscore)
        {
            Highscore = score;
            score = 0;
        }
        // ^This is the error^

        if (Highscore == Latescore)
        {

        }
        else
        {
        PlayerPrefs.SetInt("Highscore",Highscore);
        }
    }

    void LateUpdate()
    {
        Latescore = Highscore;
    }
}

请帮助

Thx 布伦

解决方法

您需要> =,而不是=>(翻转订单) 您只能进行> =进行比较,因为=>用于lambda表达式

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。