Created
April 20, 2015 09:16
-
-
Save suakig/5347cdb71739f5b4f3c5 to your computer and use it in GitHub Desktop.
TimeSample.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System; | |
using System.Net; | |
using System.Net.Cache; | |
using System.IO; | |
using System.Text.RegularExpressions; | |
public class TimeSample : MonoBehaviour | |
{ | |
void Update() | |
{ | |
if (Input.GetMouseButtonDown (0)) { | |
DateTime now = DateTimeNist.Now; | |
Debug.Log ("DateNistTime.Now " + now.ToString ("yyyy/MM/dd (ddd) HH:mm:ss") + "\n" + | |
"差分 " + (now - Load ()).TotalSeconds | |
); | |
Save (now); | |
} | |
} | |
void Save(DateTime now) | |
{ | |
// 時刻の保存 | |
PlayerPrefs.SetString ("DateNistTimeNow", now.ToBinary().ToString() ); | |
PlayerPrefs.Save (); | |
} | |
DateTime Load() | |
{ | |
string datetimeString = PlayerPrefs.GetString ("DateNistTimeNow", "0"); | |
return System.DateTime.FromBinary (System.Convert.ToInt64 (datetimeString)); | |
} | |
} | |
// Debug.Log ("DateTime.MinValue " + DateTime.MinValue.ToString("yyyy/MM/dd (ddd) HH:mm:ss"));//.ToBinary ().ToString ()); | |
// Debug.Log ("DateTime.Now " + DateTime.Now.ToString("yyyy/MM/dd (ddd) HH:mm:ss"));//.ToBinary ().ToString ()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment