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 EntropicJoey · Apr 28, 2012 at 05:50 AM · c#

invalid arguements for UIToolkit C#

here is my error,-- ive tried everything but i have no real scripting experience lol help would be appreciated, --Assets/Healthbar.cs(10,33): error CS1502: The best overloaded method match for UIProgressBar.create(UIToolkit, string, int, int, bool, int)' has some invalid arguments well thats the error i get anytime i deviate from the script shown, heres the error i am gettingas is sorry for the mistake in posting this alone lol Assets/Healthbar.cs(10,33): error CS1501: No overload for method create' takes `8' arguments

heres the script

 using UnityEngine;
 using System.Collections;
 
 public class Healthbar : MonoBehaviour {
     private UIProgressBar _health; 
     private bool _grow = false;
     private float _val = .01f;
     
     void Start () {
     _health = UIProgressBar.create(UI.firstToolkit, "progressBar.png", "progressBarBorder.png", 5, 3, 0, 0, false);
     _health.positionFromTopLeft( .01f, .01f);
     _health.resizeTextureOnChange = true;
     _health.value = .9f;
         
     }
     void Update () {
         if( !_grow && _health.value == 0)
             _grow = true;
         if( !_grow && _health.value == 1)
             _grow = false;
       
         if( _grow)
             _health.value += _val;
         else
             _health.value -= _val;
     }
 }



and the code its using or what not,

 using UnityEngine;
 using System;
 
 
 public class UIProgressBar : UISprite
 {
     public bool rightToLeft;
     
     private float _value = 0;
     private float _barOriginalWidth;
     private UIUVRect _barOriginalUVframe;
     private bool _resizeTextureOnChange = false;
     
     
     public static UIProgressBar create( string barFilename, int xPos, int yPos )
     {
         return create( UI.firstToolkit, barFilename, xPos, yPos, false, 3 );
     }
 
 
     public static UIProgressBar create( UIToolkit manager, string barFilename, int xPos, int yPos, bool rightToLeft, int depth )
     {
         var textureInfo = manager.textureInfoForFilename( barFilename );
         var frame = new Rect( xPos, yPos, textureInfo.frame.width, textureInfo.frame.height );
         
         if( rightToLeft )
             frame.x = xPos + (int)textureInfo.frame.width;
 
         var progressBar = new UIProgressBar( manager, frame, depth, textureInfo.uvRect, rightToLeft );
         
         return progressBar;
     }
     
     
     public UIProgressBar( UIToolkit manager, Rect frame, int depth, UIUVRect uvFrame, bool rightToLeft ):base( frame, depth, uvFrame )
     {
         manager.addSprite( this );
         
         // Save the bars original size
         _barOriginalWidth = frame.width;
         _barOriginalUVframe = uvFrame;
         this.rightToLeft = rightToLeft;
 
         // Update the bar size based on the value
         if( rightToLeft )
             setSize( _value * -_barOriginalWidth, frame.height );
         else
             setSize( _value * _barOriginalWidth, frame.height );
     }
 
 
     public bool resizeTextureOnChange
     {
         get { return _resizeTextureOnChange; }
         set
         {
             if( _resizeTextureOnChange != value )
             {
                 // Update the bar UV's if resizeTextureOnChange is set
                 if( value )
                 {
                     UIUVRect newUVframe = _barOriginalUVframe;
                     newUVframe.uvDimensions.x *= _value;
                     uvFrame = newUVframe;
                 }
                 else // Set original uv if not
                 {
                     uvFrame = _barOriginalUVframe;
                 }
 
                 // Update the bar size based on the value
                 if( rightToLeft )
                     setSize( _value * -_barOriginalWidth, height );
                 else
                     setSize( _value * _barOriginalWidth, height );
 
                 _resizeTextureOnChange = value;
             }
         }
     }
     
 
     // Current value of the progress bar.  Value is always between 0 and 1.
     public float value
     {
         get { return _value; }
         set
         {
             if( value != _value )
             {
                 // Set the value being sure to clamp it to our min/max values
                 _value = Mathf.Clamp( value, 0, 1 );
                 
                 // Update the bar UV's if resizeTextureOnChange is set
                 if( resizeTextureOnChange )
                 {
                     // Set the uvFrame's width based on the value
                     UIUVRect newUVframe = _barOriginalUVframe;
                     newUVframe.uvDimensions.x *= _value;
                     uvFrame = newUVframe;
                 }
 
                 // Update the bar size based on the value
                 if( rightToLeft )
                     setSize( _value * -_barOriginalWidth, height );    
                 else
                     setSize( _value * _barOriginalWidth, height );
             }
         }
     }
 }
 and yes im following BZA tutorials!! 
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

1 Reply

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

Answer by syclamoth · Apr 28, 2012 at 05:57 AM

The problem happens because you are calling a function that does not exist! There is no such function with the signature-

 create(UIToolkit, string, string, int, int, int, int, bool)

The only possible functions with this name go

 create(UIToolkit, string, int, int, bool, int)

and

 create(string, int, int)

What do all the other numbers mean? You can't just add paramaters and expect the function to magically know how to use them. Try modifying your code to obey one of the two valid function declarations:

 _health = UIProgressBar.create(UI.firstToolkit, "progressBar.png", 5, 3);
Comment
Add comment · Show 6 · 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 EntropicJoey · Apr 28, 2012 at 06:02 AM 0
Share

thank you for your response! the numbers i thought were places on the screen for them to show, i was unaware they had no function lol i am following a tutorial so i dont really understand 100 what i am doing lol but ill try what you suggested, the reason uitoolkit is in thereis cause it was added as a fix, suggested by someone on the video of the tutorial, but wasnt part of the original code, and i get the same error either way lol sorry if i am hard to understand tired

avatar image EntropicJoey · Apr 28, 2012 at 06:08 AM 0
Share

im just too newb, lol, i copy pasted perfectly, the line says takes 4 arguements, and after ive tried variations of all sorts and it gives the same error, lol

avatar image EntropicJoey · Apr 28, 2012 at 12:08 PM 0
Share

also when i remove UI.toolkit from it like it is in the video i am watching, the errors have finally gone away (with your suggested line of code edited i mean) but it still doesnt work lol

avatar image syclamoth · Apr 29, 2012 at 08:56 AM 0
Share

Well, I'm afraid I can't help you with UIToolkit specific stuff, because I didn't write it, and I've never used it...

avatar image EntropicJoey · May 29, 2012 at 03:48 PM 0
Share

thanks kindly though, i dont remember the fix but it was fixed

Show more comments

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Distribute terrain in zones 3 Answers

Multiple Cars not working 1 Answer

Problems with Audio Sources 1 Answer

How do I load customized characters into my next scene? 2 Answers

C# how to have a part of an object rotate while animation is being played 2 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