BCE0051: Operator '>' cannot be used with a left hand side of type 'UnityEngine.UI.Text' and a right hand side of type 'int'.
#pragma strict
var resim : UI.Image;
var cantabtn : UI.Button;
var odun : UI.Text;
var odunsys : int;
var cubuk : int;
var cubuktext : UI.Text;
var cubukbtn : UI.Button;
function Start () {
cubukbtn.enabled = false;
resim.enabled = false;
odun.enabled = false;
}
function Update () {
cubuktext.text = "Cubuk : "+cubuk;
odun.text = "Odun : " +odunsys;
var fwd = transform.TransformDirection(Vector3.forward);
var hit : RaycastHit;
Debug.DrawRay(transform.position,fwd*4,Color.red);
if(Physics.Raycast(transform.position,fwd,hit,4)){
if(hit.collider.tag == "odun"){
Debug.Log("Oduuunnn");
if(Input.GetKeyDown(KeyCode.E)){
odunsys+=1;
Destroy(hit.collider.gameObject);
}
}
}
Crafting();
}
function Crafting() {
if(odun > 0){
cubukbtn.enabled = true;
}else{
cubukbtn.enabled = false;
}
}
function Cubukbtnfnc () {
odun-=1;
cubuk+=1;
}
function menubtn () {
if(resim.enabled == false){
resim.enabled = true;
}else{
resim.enabled = false;
}
}
function menubtn2 () {
if(odun.enabled == false){
odun.enabled = true;
}else{
odun.enabled = false;
}
}
Comment
Problem: Assets/envanter.js(35,9): BCE0051: Operator '>' cannot be used with a left hand side of type 'UnityEngine.UI.Text' and a right hand side of type 'int'.
and
Assets/envanter.js(43,5): BCE0051: Operator '-' cannot be used with a left hand side of type 'UnityEngine.UI.Text' and a right hand side of type 'int'.
Answer by corn · Jan 04, 2016 at 05:38 PM
Just as the error messages say, odun is a UI.Text, not an int, so I guess you meant to use odunsys instead and those errors are typos. The errors are in these two functions :
function Crafting() {
if(odun > 0){
cubukbtn.enabled = true;
}else{
cubukbtn.enabled = false;
}
}
function Cubukbtnfnc () {
odun-=1;
cubuk+=1;
}
It should actually be :
function Crafting() {
if(odunsys > 0){
cubukbtn.enabled = true;
}else{
cubukbtn.enabled = false;
}
}
function Cubukbtnfnc () {
odunsys-=1;
cubuk+=1;
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612054656im_/https://answers.unity.com/themes/thub/images/avi.jpg)