Welcome,
Guest
. Please
login
or
register
.
May 28, 2023, 01:09:28 AM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
RealTime problem
« previous
next »
Print
Pages: [
1
]
Author
Topic: RealTime problem (Read 2803 times)
Capyvara
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 5
RealTime problem
«
on:
June 28, 2014, 08:07:13 PM »
Hi,
Yesterday I faced one Unity bug while trying to play a UITweener on the OnEnable() of one of my scripts, for some reason it delayed a several seconds before starting, I found out it was related to this:
http://forum.unity3d.com/threads/realtimesincestartup-is-not-0-in-first-awake-call.205773/
Basically the Time.realtimeSinceStartup isn't updated yet in the Awake() / OnEnable() calls when the scene is entering play mode in editor.
In order to prevent this I've made some workarounds in RealTime class, not sure if it's the best option (also not well tested):
static
void
Spawn
(
)
{
GameObject go
=
new
GameObject
(
"_RealTime"
)
;
DontDestroyOnLoad
(
go
)
;
mInst
=
go
.
AddComponent
<
RealTime
>
(
)
;
mInst
.
mRealTime
=
Time
.
realtimeSinceStartup
;
mInst
.
mInitialRealTime
=
mInst
.
mRealTime
;
}
void
Update
(
)
{
float
rt
=
Time
.
realtimeSinceStartup
;
if
(
rt
<
mRealTime
)
rt
+=
mInitialRealTime
;
mRealDelta
=
Mathf
.
Clamp01
(
rt
-
mRealTime
)
;
mRealTime
=
rt
;
}
Logged
Nicki
Global Moderator
Hero Member
Thank You
-Given: 33
-Receive: 141
Posts: 1,768
Re: RealTime problem
«
Reply #1 on:
June 29, 2014, 04:11:55 PM »
Arguably it should just use
http://docs.unity3d.com/ScriptReference/Time-unscaledTime.html
now.
Logged
Capyvara
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 5
Re: RealTime problem
«
Reply #2 on:
June 29, 2014, 06:58:44 PM »
Quote from: Nicki on June 29, 2014, 04:11:55 PM
Arguably it should just use
http://docs.unity3d.com/ScriptReference/Time-unscaledTime.html
now.
The problem is that it's Unity 4.5 only, and NGUI supports 4.3+
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: RealTime problem
«
Reply #3 on:
June 29, 2014, 10:45:45 PM »
Ah, I didn't know it was finally added. I remember mentioning that it was needed back in 2012 when I was in Unity. Good news. I've adjusted the RealTime class accordingly.
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
RealTime problem