这段代码有什么问题??!?!?! [英] Whats wrong with this code??!?!?!

查看:81
本文介绍了这段代码有什么问题??!?!?!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用System.Collections;

使用System.Collections.Generic;

使用UnityEngine;



公共类检测碰撞:MonoBehaviour {
$


    private var score:int = 0;

    var guiScore:GUIText;



   功能开始()

{

    guiScore.text ="得分:0" ;;

}



函数更新()

{< br $> b $ b $
}




函数OnCollisionEnter(Col:Collision)

{

  &NBSP; if(col.gameObject.name ==" Pill")

  &NBSP; {

  &NBSP; &NBSP; &NBSP;得分+ = 5;

  &NBSP; &NBSP; &NBSP; guiScore.text ="得分:" +分数;

  &NBSP; &NBSP; &NBSP;打印("与药丸碰撞");¥b $ b  &NBSP; }
}

}

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

public class Detection collision : MonoBehaviour {

    private var score: int = 0;
    var guiScore: GUIText;

    function Start()
{
    guiScore.text = "Score: 0";
}

function Update()
{

}


function OnCollisionEnter(Col : Collision)
{
    if (col.gameObject.name == "Pill")
    {
        score += 5;
        guiScore.text = "Score: " + score;
        print("collide with Pill");
    }
}
}

推荐答案

我认为  guiScore.text ="得分:" +得分;

得分为int且会有"得分:"+得分.ToString();

score is int and there would be "Score: "+score.ToString();

可能您是否获得了有关某些错误的更多信息?

Could you get more information about some error or something?


这篇关于这段代码有什么问题??!?!?!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆