Support => NGUI 3 Support => Topic started by: Paul1 on July 27, 2014, 07:16:32 PM
Title: Enabling Position Tweening (or any other NGUI script) from another function
Post by: Paul1 on July 27, 2014, 07:16:32 PM
Hi I've recently purchased NGUI and would first like to say thanks for such a great time saving efficient tool 8-)
I'm fairly new to programming and am only familiar with Unity's Javascript, so not sure if this is a NGUI or Unity question
I'm trying to integrate NGUI in to a game I'm making. I've been stuck on this problem for a couple of days now so help would be greatly appreciated
As my character moves around a house I want to hide and reveal different ui buttons and graphics dependant on the room they are in. I'm using the NGUI Tween Position script attached to the button to move the item (I note that enabling this script via the inspector check box gives the desired result) .
The Problem is I can't find a way to enable this tween or reverse it via a custom function I call when the character exits or enters a room.
Could anyone advise? (with code snippets or an example if possible as I'm quite junior when it comes to programming)
Thanks in advance ;D
Title: Re: Enabling Position Tweening (or any other NGUI script) from another function
Post by: ArenMook on July 27, 2014, 11:15:27 PM
GetComponent<UITween>().PlayForward() or PlayReverse().
Title: Re: Enabling Position Tweening (or any other NGUI script) from another function
Post by: Paul1 on July 30, 2014, 07:51:20 AM
Thank you for the help, I've been trying to test the code snippet in (what I think is) it's simplest form but get unexpected token errors. This code is in a script on a different game object.
I don't think I understand how UITweener should be accessed? :)
I thought it maybe the syntax so I changed <UITweener> to (UITweener) but this produces the error unknown identifier: 'UITweener'
Any ideas?
Thanks again in advance
Title: Re: Enabling Position Tweening (or any other NGUI script) from another function
Post by: ArenMook on July 30, 2014, 10:46:30 AM
You are doing it right, but likely not on the correct object. UITweener is the base class for all tweens. Your code will work only if "mybutton" is what has the tween on it.
Title: Re: Enabling Position Tweening (or any other NGUI script) from another function
Post by: Paul1 on July 31, 2014, 10:40:08 AM
Thanks for the help again, I've checked and I did have the correct object assigned in the inspector, "but_food_l" has the TweenPosition script attached to it
I still get the same error BCE0005: Unknown identifier: 'UITweener'.
I'm still struggling to identify where the problem actually is?
Is it because... -My syntax is incorrect? -I'm trying to access a C# script from a JS script? -It's a compile order problem like mentioned here? http://answers.unity3d.com/questions/510862/bce0018-the-name-tweenposition-does-not-denote-a-v.html (http://answers.unity3d.com/questions/510862/bce0018-the-name-tweenposition-does-not-denote-a-v.html)
I've tried to implement many solutions but they each seem to have their own dead ends, I'm not really sure where to go from here?
Title: Re: Enabling Position Tweening (or any other NGUI script) from another function
Post by: ArenMook on July 31, 2014, 12:12:24 PM
I don't know javascript so I can't be of much help, but unless you followed instructions from FAQ on how to get NGUI to work with javascript, it simply won't work at all.