【发布时间】:2018-08-06 07:58:35
【问题描述】:
我已经四处寻找解决方案,但到目前为止没有任何效果,这是我的代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class BirdController : MonoBehaviour
{
public float jumpVelocity;
public Text jumpCooldownDisplayText = "";
public float speed = 18;
private Rigidbody rb;
public float jumpCooldown = 0f;
// Use this for initialization
void Start ()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void FixedUpdate ()
{
jumpCooldown -= Time.deltaTime;
jumpCooldownDisplayText = Mathf.Round (jumpCooldown).ToString();
if (Input.GetButtonDown ("Jump") && jumpCooldown <= 0)
{
rb.velocity = Vector3.up * jumpVelocity;
jumpCooldown = 0.5f;
}
float hAxis = Input.GetAxis("Horizontal");
float vAxis = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(hAxis*speed, 0, vAxis*speed) * Time.deltaTime;
rb.MovePosition(transform.position + movement);
}
}
我得到的错误是“无法隐式转换类型string' toUnityEngine.UI.Text'”。我将此错误放入代码的不同位置。
【问题讨论】:
标签: string user-interface unity3d text