Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unity3d 有人能检查一下我的错误并指导我解决问题吗_Unity3d_Unityscript - Fatal编程技术网

Unity3d 有人能检查一下我的错误并指导我解决问题吗

Unity3d 有人能检查一下我的错误并指导我解决问题吗,unity3d,unityscript,Unity3d,Unityscript,下面是我的错误基本上是我做的一个游戏,这是我的手工艺脚本,这是我犯的错误有人能帮我吗 Assets/scrpts/Crafting.js(91,81):BCE0024:类型“UnityEngine.GUIContent”没有与参数列表(UnityEngine.GameObject,String)匹配的可见构造函数。 #pragma strict var MenuSkin : GUISkin; //References var player : GameObject; var mainCame

下面是我的错误基本上是我做的一个游戏,这是我的手工艺脚本,这是我犯的错误有人能帮我吗

Assets/scrpts/Crafting.js(91,81):BCE0024:类型“UnityEngine.GUIContent”没有与参数列表(UnityEngine.GameObject,String)匹配的可见构造函数。

#pragma strict

var MenuSkin : GUISkin;

//References
var player : GameObject;
var mainCamera : GameObject;
var arms : GameObject;

//Icons
var campfireIcon : Texture;
var tentIcon : Texture;
var woodwallicon : Texture;
var spareIcon2 : Texture;
var spareIcon3 : Texture;
var spareIcon4 : Texture;

//Player prefabs
var campFire : GameObject;
var tent : GameObject;
var woodwall : GameObject;
var spare2 : GameObject;
var spare3 : GameObject;
var spare4 : GameObject;


private var showGUI : boolean = false;

private var invScript : Inventory;

function Start()
{
    invScript = GetComponent(Inventory);
}

function Update()
{
    if(Input.GetKeyDown("c"))
    {
        showGUI = !showGUI;
    }

    if(showGUI == true)
    {
        Time.timeScale = 0;
        player.GetComponent(FPSInputController).enabled = false;
        player.GetComponent(MouseLook).enabled = false;
        mainCamera.GetComponent(MouseLook).enabled = false;
        arms.GetComponent(PlayerControl).enabled = false;
    }

    if(showGUI == false)
    {
        Time.timeScale = 1;
        player.GetComponent(FPSInputController).enabled = true;
        player.GetComponent(MouseLook).enabled = true;
        mainCamera.GetComponent(MouseLook).enabled = true;
        arms.GetComponent(PlayerControl).enabled = true;
    }
}

function OnGUI()
{
    if(showGUI == true)
    {
        GUI.skin = MenuSkin;
            GUI.BeginGroup(new Rect(Screen.width / 2 - 150, Screen.height / 2 - 150, 300, 300));
                GUI.Box(Rect(0, 0, 300, 300), "Crafting System");

                if(GUI.Button(Rect(10, 50, 50, 50), GUIContent (campfireIcon, "Build a campfire")))
                {
                    if(invScript.wood >= 6)
                    {
                        campFire.SetActive(true);
                        invScript.wood -= 6;
                        invScript.stone -= 3;
                    }
                }

                if(GUI.Button(Rect(10, 120, 50, 50), GUIContent (tentIcon, "Build a tent")))
                {
                    if(invScript.wood >= 6 && invScript.stone >= 3)
                    {
                        tent.SetActive(true);
                        invScript.wood -= 6;
                        invScript.stone -= 3;
                    }
                }


                if(GUI.Button(Rect(10, 190, 50, 50), GUIContent (woodwall, "Build a wooden wall")))
                {
                    if(invScript.wood >= 3 && invScript.iron >= 1)
                    {
                        woodwall.SetActive(true);;
                        invScript.wood -= 3;
                        invScript.iron -= 1;
                    }
                }

您将收到一个错误,因为您传递了交换的参数,
GUIContent
构造函数如下所示

GUIContent(text: string, image: Texture)
因此,您可能需要更改输入以适应可用的构造函数

GUIContent ("Build a campfire", campfireIcon)

在将来的需求检查中进一步检查

检查GUI内容的可用构造函数,确保您的构造函数与其中一个匹配。也就是说,在构造CUIContent对象时,请确保其参数与提供的构造函数之一所需的参数匹配。这不是Java,不是任何延伸。是的,请将标记更改为javascript而不是javanope,它甚至不是javascript