- Home /
BCE0017 error with GUI scripts
I've been editing my GUI scripts because the images for my vitals where not shrinking when my health/stamina was depleting. I changed the script back to what it was, but now I have this error I did not have before:
"Assets/Scripts/GUI/GUI_HUD.js(38,39): BCE0017: The best overload for the method 'GUI_CustomControls.LeftStatusMeter(UnityEngine.Texture, Object, UnityEngine.Texture, Object, UnityEngine.Texture)' is not compatible with the argument list '(UnityEngine.Texture2D, float, float, UnityEngine.Texture2D, UnityEngine.Texture2D)'."
What is causing this? Also, is this (or something else) causing my GUI textures not to shrink/fill up when I lose/gain health/stamina?
GUI_CustomControls:
//GUI_CustomControls: Contains the custom compunt control classes for use elsewhere in the GUI_CustomControls
//Item HUD Button------------------------------------------------
//Displays the button, button, correct overlay item picture, and the number of the item currently in Moalia's Invo.
function InvoHudButton(screenPos: Rect, numAvailable : int, itemImage: Texture, itemtooltip: String) : boolean
{
if(GUI.Button(screenPos, GUIContent(itemImage, itemtooltip), "HUD Button"))
return true;
GUI.Label(Rect(screenPos.xMax - 20, screenPos.yMax - 25, 20, 20), numAvailable.ToString());
//Display area for tooltips
GUI.Label(Rect(20, Screen.height - 130, 500, 100), GUI.tooltip);
}
//Left hand health------------------------------------
function LeftStatusMeter(charImage : Texture, health, hBarImage : Texture, stamina, sBarImage : Texture)
{
GUI.BeginGroup(Rect(0,0, 330, 125));
//Place front bars
GUI.BeginGroup(Rect(120, 20, 218 * (health/100.0) + 10, 90));
GUI.Label(Rect(0, 0, 272, 90), hBarImage);
GUI.EndGroup();
GUI.BeginGroup(Rect(120, 0, 218 * (stamina/100.0) + 10, 90));
GUI.Label(Rect(0, 0, 272, 90), sBarImage);
GUI.EndGroup();
//Place body circle
GUI.Label(Rect(0, 0, 330, 125), charImage);
GUI.EndGroup();
}
@script AddComponentMenu("GUI/CustomControls")
GUI_HUD:
//GUI_HUD: DIsplays the pertinent information for Moalia
//Set up textures----------------------------------------
//For larger games, this should be done programmatically
var skin : GUISkin;
var staminaInjectorImage : Texture2D;
//Left vital tex
var lbarImage : Texture2D;
var lhbar : Texture2D;
var lsbar : Texture2D;
var MoaliaImage : Texture2D;
//---------------------------------------------------------
private var customControls : GUI_CustomControls;
private var playerInfo : Moalia_Status;
private var playerInvo : Moalia_Inventory;
private var playerAttack : Moalia_AttackController;
private var player;
//Initialize player info--------------------------------
function Awake()
{
playerInfo = FindObjectOfType(Moalia_Status);
customControls = FindObjectOfType(GUI_CustomControls);
playerInvo = FindObjectOfType(Moalia_Inventory);
playerAttack = FindObjectOfType(Moalia_AttackController);
player = GameObject.FindWithTag("Player");
}
//Display------------------------------------------
function OnGUI()
{
if(skin)
GUI.skin = skin;
//Moalia's vitals
customControls.LeftStatusMeter(MoaliaImage, playerInfo.health, playerInfo.stamina, lhbar, lsbar);
//Non-usable inventory buttons--------------------------
customControls.InvoHudButton(Rect(Screen.width - 210, Screen.height - 100, 93, 95), playerInvo.GetItemCount(InventoryItem.STAMINA_INJECTOR), staminaInjectorImage, "Avalable Stamina Injectors in inventory.");
}
@script ExecuteInEditMode()
@script AddComponentMenu("GUI/HUD")
Answer by tanoshimi · Aug 23, 2014 at 07:26 PM
The error message literally explains the entire problem to you. In GUICustomControls you've defined a function called LeftStatusMeter
, and said that it requires the following parameters:
charImage : Texture,
health, (which you haven't specified a type for, so is just a generic "object")
hBarImage : Texture,
stamina, (which you haven't specified a type for, so is just a generic "object")
sBarImage : Texture
Then in line 38 of GUIHUD you're trying to call that function, but are passing it the following parameters:
MoaliaImage, (Texture2D)
playerInfo.health, (float)
playerInfo.stamina, (float)
lhbar (Texture2D)
lsbar (Texture2D)
Make sure all the parameters in the function definition are declared with an appropriate type, and then call the function with the right parameters corresponding to those types.
I changed the LeftStatus$$anonymous$$eter to
function LeftStatus$$anonymous$$eter(charImage : Texture, health : float, hBarImage : Texture, sta$$anonymous$$a : float, sBarImage : Texture)
{
I'm still getting the error, however, I don't know what to add to the variables and or find the changes needed to the areas of the scripts.
Right, so now your function expects:
Texture, float, Texture, float, Texture
But you're still passing it:
Texture2D, float, float, Texture2D, Texture2D
...
I rearranged the order and the error is gone. Yet I'm still having one problem. $$anonymous$$y sta$$anonymous$$a on the inspector goes changes when I run and stop, but my sta$$anonymous$$a bar does not shrink. (Same with health).
Update: the bar actually does shrink, but only if the current value is like less than 40/35. So what number values control that?
Answer by gjf · Aug 23, 2014 at 04:49 PM
you didn't specify the type for health
GUI_CustomControls - line15
function LeftStatus$$anonymous$$eter(charImage : Texture, health, hBarImage : Texture, sta$$anonymous$$a, sBarImage : Texture)
function LeftStatus$$anonymous$$eter(charImage : Texture, playerInfo.health, hBarImage : Texture, playerInfo.sta$$anonymous$$a, sBarImage : Texture)
And I'm getting these errors:
"Assets/Scripts/GUI/GUI_CustomControls.js(15,57): BCE0043: Unexpected token: .."
"Assets/Scripts/GUI/GUI_CustomControls.js(15,97): BCE0043: Unexpected token: .."
Your answer
![](https://koobas.hobune.stream/wayback/20220613161336im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
BCE0017 Animations 1 Answer
Trying to instantiate random enemy prefab from array 3 Answers
Mouse look script help 1 Answer
Setting Scroll View Width GUILayout 1 Answer
Can someone help me fix my Javascript for Flickering Light? 6 Answers