- Home /
UnityEngine.Rect' does not have a visible constructor that matches the....
Ok, so i made this script and i came up with an error that i cant seem to fix. UnityEngine.Rect' does not have a visible constructor that matches the argument list (float, int, int)
I looked up other solutions but i still couldnt find the problem
the error is on 72,28
var Planks : int;
var Sticks : int;
var Stone : int;
var Rocks : int;
var WoodWall : Transform;
var WoodHatchet : Transform;
var StoneHatchet : Transform;
var Knife : Transform;
var Menu = false;
var look01 : MouseLook;
var look02 : MouseLook;
var charController : CharacterController;
function Start ()
{
look01 = gameObject.GetComponent(MouseLook);
look01 = GameObject.Find("MainCamera").GetComponent(MouseLook);
charController = gameObject.GetComponent(CharacterController);
}
function Mining(Rock : int)
{
Stone += Rocks;
}
function TreeMining(Wood : int)
{
Sticks += Wood;
}
function Update ()
{
if(Menu == false)
{
look01.enabled = true;
look02.enabled = true;
charController.enabled = true;
}
//} NOT NEEDED
if(Menu == true)
{
look01.enabled = false;
look02.enabled = false;
charController.enabled = false;
}
//} NOT NEEDED
if (Input.GetKeyDown(KeyCode.Tab))
{
Menu = !Menu;
}
//New one needed here
}
function WeaponKnife()
{
if(Sticks >= 2)
{
if(Stone >=3)
{
Knife.active = true;
Stone -= 3;
Sticks -= 2;
Menu = !Menu;
}
}
}
function OnGUI ()
{
if(Menu == true)
{
if (GUI.Button(Rect(Screen.width*0.5-50, 200-20,100-40),"Knfie"))
{
WeaponKnife();
}
}
}
I think you need to give it a 4th parameter. If I remember correctly it takes (xpos, ypos, xlength, y length) and you give it only 3 arguments. Also you misspelled "$$anonymous$$nife", but that wouldn't give you an error.
Try this:
if (GUI.Button(Rect(Screen.width*0.5-50, 180,60, 30),"$$anonymous$$nife"))
{
Weapon$$anonymous$$nife();
}
}
Answer by SkaredCreations · Apr 13, 2014 at 09:29 AM
You are missing the parameter "height" in the constructor of Rect at line 72
Your answer
Follow this Question
Related Questions
Semicolon error using JS 1 Answer
[CLOSED] UnityScript - enum to numeric value error 1 Answer
Error BCE0044 plz help 0 Answers
How to use if statement with var? 3 Answers
Animation Crossfade won't play but Animation Play does 1 Answer