有人可以查看我的错误并指导我修复

时间:2015-01-20 21:25:03

标签: unity3d unityscript

以下是我的错误基本上为一个游戏即时通讯制作这是我的制作脚本它的trowing我这个错误可以有人帮助

资产/ 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;
                    }
                }

1 个答案:

答案 0 :(得分:0)

您收到错误,因为您已经传递了swapped参数,GUIContent构造函数看起来像,

GUIContent(text: string, image: Texture)

因此,您可能需要更改输入以适应可用的构造函数。

GUIContent ("Build a campfire", campfireIcon)

今后还需要检查Unity Scripting API