Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by CyberArtist · Aug 23, 2014 at 04:39 PM · javascriptbce0017

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")
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

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.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image CyberArtist · Aug 23, 2014 at 07:46 PM 0
Share

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.

avatar image tanoshimi · Aug 23, 2014 at 08:06 PM 0
Share

Right, so now your function expects:

 Texture, float, Texture, float, Texture

But you're still passing it:

 Texture2D, float, float, Texture2D, Texture2D

...

avatar image CyberArtist · Aug 23, 2014 at 08:45 PM 0
Share

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?

avatar image
0

Answer by gjf · Aug 23, 2014 at 04:49 PM

you didn't specify the type for health

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image CyberArtist · Aug 23, 2014 at 04:52 PM 0
Share

On what script?

avatar image gjf · Aug 23, 2014 at 05:54 PM 0
Share

GUI_CustomControls - line15

 function LeftStatus$$anonymous$$eter(charImage : Texture, health, hBarImage : Texture, sta$$anonymous$$a, sBarImage : Texture)
avatar image CyberArtist · Aug 23, 2014 at 06:48 PM 0
Share
 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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges