Welcome,
Guest
. Please
login
or
register
.
June 05, 2026, 06:02:18 AM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Is it possible to tween all objects within a panel?
« previous
next »
Print
Pages: [
1
]
Author
Topic: Is it possible to tween all objects within a panel? (Read 8041 times)
xikky
Newbie
Thank You
-Given: 0
-Receive: 1
Posts: 46
Is it possible to tween all objects within a panel?
«
on:
August 02, 2013, 08:42:23 AM »
I tried alpha tween on a panel but the tween is only applied to sprites that are direct children of the panel. Other sprites contained as children of Gameobjects, within the panel are not affected. Can I fix this?
Logged
Malzbier
Jr. Member
Thank You
-Given: 0
-Receive: 0
Posts: 93
Re: Is it possible to tween all objects within a panel?
«
Reply #1 on:
August 02, 2013, 09:40:16 AM »
Its very easy to build a tweener for panel alpha. (Took me 1 minute)
(Converted form the normal alpha tween script)
using
UnityEngine
;
/// <summary>
/// Tween the panels's alpha.
/// </summary>
[
AddComponentMenu
(
"NGUI/Tween/PanelAlpha"
)
]
public
class
TweenPanelAlpha
:
UITweener
{
public
float
from
=
1f
;
public
float
to
=
1f
;
Transform mTrans
;
UIPanel mPanel
;
/// <summary>
/// Current alpha.
/// </summary>
public
float
alpha
{
get
{
return
mPanel
.
alpha
;
}
set
{
mPanel
.
alpha
=
value
;
}
}
/// <summary>
/// Find all needed components.
/// </summary>
void
Awake
(
)
{
mPanel
=
GetComponentInChildren
<
UIPanel
>
(
)
;
}
/// <summary>
/// Interpolate and update the alpha.
/// </summary>
override
protected
void
OnUpdate
(
float
factor,
bool
isFinished
)
{
alpha
=
Mathf
.
Lerp
(
from
, to, factor
)
;
}
/// <summary>
/// Start the tweening operation.
/// </summary>
static
public
TweenAlpha Begin
(
GameObject go,
float
duration,
float
alpha
)
{
TweenAlpha comp
=
UITweener
.
Begin
<
TweenAlpha
>
(
go, duration
)
;
comp
.
from
=
comp
.
alpha
;
comp
.
to
=
alpha
;
return
comp
;
}
}
Logged
xikky
Newbie
Thank You
-Given: 0
-Receive: 1
Posts: 46
Re: Is it possible to tween all objects within a panel?
«
Reply #2 on:
August 02, 2013, 11:51:39 AM »
Thanks! works perfect.
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: Is it possible to tween all objects within a panel?
«
Reply #3 on:
August 02, 2013, 08:12:50 PM »
Built-in TweenAlpha works with panels.
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Is it possible to tween all objects within a panel?