- Home /
Question by
Ammar91 · Aug 23, 2019 at 05:31 AM ·
timesubtracting
time parsing making Game unable to run on editor
I've tried everything and tired of searching, I'm trying to count the time since last the player played the game in order to increase energy value. but seems that there is problem in parsing of time string (the issue begun to happen when I added these codes) when I run it on the editor the editor stuck with no logging.
private void Start()
{
// to calculate time since player left app to be used for energy increment
currentTime = DateTime.Now.ToString();
lastTime = PlayerPrefs.GetString("lastTime", currentTime);
if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
{
timeDT = Convert.ToDateTime(currentTime , null);
CurrentTimeDT = Convert.ToDateTime(lastTime, null);
timeSpan = timeDT.Subtract(CurrentTimeDT);
timeDifference = int.Parse(timeSpan.TotalSeconds.ToString());
} else if (Application.platform == RuntimePlatform.WindowsEditor)
{
lastTime = lastTime.Substring(10);
currentTime = currentTime.Substring(10);
timeDT = DateTime.ParseExact(currentTime, "h:mm:ss tt" , null);
CurrentTimeDT = DateTime.ParseExact(lastTime,"h:mm:ss tt", null);
timeSpan = timeDT.Subtract(CurrentTimeDT);
timeDifference = int.Parse(timeSpan.TotalSeconds.ToString());
}
energy = PlayerPrefs.GetInt("energy", 5); //get last saved energy
energy += Mathf.Abs(timeDifference / 300); //add one energy every 5 minutes since the player left app
if (energy > 5) // the maximum energy amount
{
energy = 5;
}
error logs from android build logcat below
08-21 03:43:39.671 1747-2330/? I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.Serv4Me.SlidingBall/com.unity3d.player.UnityPlayerActivity bnds=[8,618][149,848]} from uid 1000 on display 0
08-21 03:43:39.671 1747-2330/? V/WindowManager: addAppToken: AppWindowToken{26711652 token=Token{13d4badd ActivityRecord{16a33eb4 u0 com.Serv4Me.SlidingBall/com.unity3d.player.UnityPlayerActivity t38}}} to stack=1 task=38 at 0
08-21 03:43:39.674 2042-2042/? W/ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1341 android.content.ContextWrapper.sendBroadcast:382 com.vphone.launcher.Stats.recordLaunch:129 com.vphone.launcher.Launcher.c:3766 com.vphone.launcher.Launcher.onClickAppShortcut:3718
08-21 03:43:39.693 1747-1770/? V/WindowManager: Adding window Window{2e196895 u0 Starting com.Serv4Me.SlidingBall} at 3 of 6 (after Window{759b336 u0 com.vphone.launcher/com.vphone.launcher.Launcher})
--------- beginning of main
08-21 03:43:39.713 2042-2042/? D/yeshen: launcher onpause
08-21 03:43:39.714 2042-2252/? W/ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.bindService:1770 android.content.ContextWrapper.bindService:539 com.google.android.gms.common.stats.zza.zza:-1 com.google.android.gms.common.stats.zza.zza:-1 com.google.android.gms.ads.identifier.AdvertisingIdClient.zzc:-1
08-21 03:43:39.752 1747-1896/? I/ActivityManager: Start proc 10674:com.Serv4Me.SlidingBall/u0a47 for activity com.Serv4Me.SlidingBall/com.unity3d.player.UnityPlayerActivity
08-21 03:43:39.764 10674-10674/? D/houdini: [10674] Initialize library(version: 5.0.7b_x.48396 RELEASE)... successfully.
08-21 03:43:40.023 10674-10674/? D/houdini: [10674] Added shared library /data/app/com.Serv4Me.SlidingBall-1/lib/arm/libmain.so for ClassLoader by Native Bridge.
08-21 03:43:40.153 1747-1760/? V/WindowManager: Adding window Window{2047b802 u0 com.Serv4Me.SlidingBall/com.unity3d.player.UnityPlayerActivity} at 3 of 7 (before Window{2e196895 u0 Starting com.Serv4Me.SlidingBall})
08-21 03:43:40.186 1747-1889/? V/WindowManager: Adding window Window{2b3bc350 u0 SurfaceView} at 3 of 8 (before Window{2047b802 u0 com.Serv4Me.SlidingBall/com.unity3d.player.UnityPlayerActivity})
08-21 03:43:40.263 1747-1770/? I/ActivityManager: Displayed com.Serv4Me.SlidingBall/com.unity3d.player.UnityPlayerActivity: +544ms
08-21 03:43:40.263 1747-1889/? W/ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1327 com.android.server.InputMethodManagerService.hideCurrentInputLocked:1992 com.android.server.InputMethodManagerService.windowGainedFocus:2082 com.android.internal.view.IInputMethodManager$Stub.onTransact:221 com.android.server.InputMethodManagerService.onTransact:873
08-21 03:43:40.272 2042-2042/? D/yeshen: launcher onstop
08-21 03:43:40.284 2042-2042/? D/Tinker.DefaultAppLike: onTrimMemory level:20
08-21 03:43:40.285 2042-2277/? W/DebugConnManager: getNetworkInfo() on networkType 1
08-21 03:43:40.392 10674-10693/? I/Unity: SystemInfo CPU = ARMv7 VFPv3 NEON, Cores = 2, Memory = 2022mb
08-21 03:43:40.392 10674-10693/? I/Unity: SystemInfo ARM big.LITTLE configuration: 2 big (mask: 0x3), 0 little (mask: 0x0)
08-21 03:43:40.394 10674-10693/? I/Unity: ApplicationInfo com.Serv4Me.SlidingBall version 1.0 build 52251d08-2db4-4bc0-b627-11ed2dc44951
08-21 03:43:40.395 10674-10693/? I/Unity: Built from '2019.2/staging' branch, Version '2019.2.1f1 (ca4d5af0be6f)', Build type 'Release', Scripting Backend 'mono', CPU 'armeabi-v7a', Stripping 'Disabled'
08-21 03:43:40.826 10674-10693/? E/EGL_emulation: [eglGetConfigAttrib] Bad attribute idx 12513
08-21 03:43:40.826 10674-10693/? E/EGL_emulation: tid 10693: eglGetConfigAttrib(761): error 0x3004 (EGL_BAD_ATTRIBUTE)
08-21 03:43:40.826 10674-10693/? E/EGL_emulation: [eglGetConfigAttrib] Bad attribute idx 12514
08-21 03:43:40.826 10674-10693/? E/EGL_emulation: tid 10693: eglGetConfigAttrib(761): error 0x3004 (EGL_BAD_ATTRIBUTE)
08-21 03:43:40.826 10674-10693/? E/EGL_emulation: [eglGetConfigAttrib] Bad attribute idx 1
08-21 03:43:40.826 10674-10693/? E/EGL_emulation: tid 10693: eglGetConfigAttrib(761): error 0x3004 (EGL_BAD_ATTRIBUTE)
08-21 03:43:40.895 10674-10693/? D/Unity: GL_EXT_debug_marker GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_depth24 GL_OES_depth32 GL_OES_element_index_uint GL_OES_texture_float GL_OES_texture_float_linear GL_OES_compressed_paletted_texture GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth_texture GL_EXT_texture_format_BGRA8888 GL_APPLE_texture_format_BGRA8888 GL_OES_texture_half_float GL_EXT_robustness GL_OES_texture_half_float_linear GL_OES_packed_depth_stencil GL_OES_vertex_half_float GL_OES_texture_npot GL_OES_rgb8_rgba8 GL_EXT_color_buffer_float ANDROID_gles_max_version_3_1 GL_OES_vertex_array_object
08-21 03:43:45.359 1747-1761/? W/SensorService: sensor 00000000 already enabled in connection 0xa1404fa0 (ignoring)
08-21 03:43:45.553 1747-1817/? D/ConnectivityService: releasing NetworkRequest NetworkRequest [ id=57, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED] ]
08-21 03:43:45.555 2042-2344/? D/ConnectivityManager.CallbackHandler: CM callback handler got msg 524296
08-21 03:43:46.593 10674-10693/? I/Unity: 12162
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
08-21 03:43:53.400 7816-7869/? E/PlayCommon: [290] afxf.d(308): Failed to connect to server for server timestamp: java.net.UnknownHostException: Unable to resolve host "play.googleapis.com": No address associated with hostname
08-21 03:43:53.450 2690-2690/? W/ChimeraUtils: Non Chimera context
08-21 03:43:53.489 7816-7869/? I/PlayCommon: [290] afxf.d(124): Connecting to server: https://play.googleapis.com/play/log?format=raw&proto_v2=true
08-21 03:43:53.494 7816-7869/? E/PlayCommon: [290] afxf.d(287): Failed to connect to server: java.net.UnknownHostException: Unable to resolve host "play.googleapis.com": No address associated with hostname
08-21 03:44:13.102 2902-10639/? E/FbnsService: receive/publish/wrong_topic; topic=231
what wrong am I doing ?
Comment