Support => NGUI 3 Support => Topic started by: piearesquared0 on October 13, 2013, 02:50:58 PM
Title: Cant change sprite via code in NGUI free
Post by: piearesquared0 on October 13, 2013, 02:50:58 PM
Ive had alot of trouble with this and im not sure if it because of my lack of experience with NGUI or lack of skill in unity, i try everything i can think of to change the sprite via code (tried both cs and js) and i get an error everytime
this
void Update ()
{
UISlicedSprite spr;
spr=this.GetComponent(UISlicedSprite);
spr.spriteName=items.items[id].name;
}
this
void Update ()
{
UISlicedSprite spr;
spr=GetComponent(UISlicedSprite);
spr.spriteName=items.items[id].name;
}
this
void Update ()
{
UISlicedSprite spr;
spr=this.gameObject.GetComponent(UISlicedSprite);
spr.spriteName=items.items[id].name;
}
and every time i get loads of errors dealing with type conversions
Assets/scripts/engine/system/invItemBox.cs(17,39): error CS0119: Expression denotes a `type', where a `variable', `value' or `method group' was expected Assets/scripts/engine/system/invItemBox.cs(17,26): error CS1502: The best overloaded method match for `UnityEngine.Component.GetComponent(System.Type)' has some invalid arguments Assets/scripts/engine/system/invItemBox.cs(17,26): error CS1503: Argument `#1' cannot convert `object' expression to type `System.Type'
ive even tried replacing the () with <> and that just adds more errors, please help!
Title: Re: Cant change sprite via code in NGUI free
Post by: Nicki on October 13, 2013, 03:57:47 PM