Welcome,
Guest
. Please
login
or
register
.
December 11, 2024, 11:13:58 PM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Set TweenPosition from/to after play
« previous
next »
Print
Pages: [
1
]
Author
Topic: Set TweenPosition from/to after play (Read 1862 times)
tnbao91original
Newbie
Thank You
-Given: 2
-Receive: 0
Posts: 41
Set TweenPosition from/to after play
«
on:
August 20, 2014, 09:39:19 AM »
Hi, can u show me how to set tweenposition from/to again after play ? I use a objectpool and need to reset it but i cant
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: Set TweenPosition from/to after play
«
Reply #1 on:
August 20, 2014, 05:46:07 PM »
GetComponent<TweenPosition>().to = ...?
or
TweenPosition.Begin(...)?
Logged
tnbao91original
Newbie
Thank You
-Given: 2
-Receive: 0
Posts: 41
Re: Set TweenPosition from/to after play
«
Reply #2 on:
August 20, 2014, 10:20:37 PM »
Thank for reply, i solved it but i dont know why this code dont work (OnFinished call UnActive)
void
OnEnable
(
)
{
worldCamera
=
NGUITools
.
FindCameraForLayer
(
Target
.
layer
)
;
uiCamera
=
NGUITools
.
FindCameraForLayer
(
gameObject
.
layer
)
;
pos
=
worldCamera
.
WorldToViewportPoint
(
Target
.
transform
.
position
)
;
pos
=
uiCamera
.
ViewportToWorldPoint
(
pos
)
;
pos
.
y
+=
0
.
20f
;
pos
.
z
=
0f
;
transform
.
position
=
pos
;
m_TweenLabel
=
gameObject
.
GetComponent
<
TweenPosition
>
(
)
;
m_TweenLabel
.
ResetToBeginning
(
)
;
m_TweenLabel
.
from
=
transform
.
localPosition
;
m_TweenLabel
.
to
=
gameObject
.
GetComponent
<
TweenPosition
>
(
)
.
from
+
Vector3
.
up
*
100
;
m_TweenLabel
.
PlayForward
(
)
;
}
public
void
UnActive
(
)
{
mTarget
=
null
;
gameObject
.
SetActive
(
false
)
;
}
But if i put m_TweenLabel.ResetToBeginning (); in UnActive this work fine
public
void
UnActive
(
)
{
mTarget
=
null
;
m_TweenLabel
.
ResetToBeginning
(
)
;
gameObject
.
SetActive
(
false
)
;
}
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: Set TweenPosition from/to after play
«
Reply #3 on:
August 22, 2014, 03:08:09 AM »
Ideally, you really should be using TweenPosition.Begin to activate the tween, not change its 'from' and 'to' manually. And for anything more complex than moving from point A to point B, you may also consider creating an animation instead.
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Set TweenPosition from/to after play