- Home /
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!!
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);
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
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
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
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...
thanks kindly though, i dont remember the fix but it was fixed
Your answer
Follow this Question
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