【Unity ライブラリ】Easy Save 2 : DateTime型のデータを保存

EasySave2でDateTime型は保存できないので、string型で保存する。

public string _sCurTimeIsLeft{
	get{
		if (ES2.Exists ("curTimeIsLeft" + _id)) {
			return ES2.Load<string> ("curTimeIsLeft" + _id);
		} else {
			return null;
		}
	}
	set{
		ES2.Save (value, "curTimeIsLeft" +  _id);
	}
}
public string _sTimeIsClicked{
	get{
		if (ES2.Exists ("timeIsClicked" + _id)) {
			return ES2.Load<string> ("timeIsClicked" + _id);
		} else {
			return null;
		}
	}
	set{
		ES2.Save (value, "timeIsClicked" +  _id);
	}
}

呼び出す側で、intやDateTime型に変換してあげる。

void Update () {
	if(SkillSource._item[_id]._bOnUseSkill){
		if( _curTimeIsLeft > 0){
			_curTimeIsLeft 		= Convert.ToInt64(SkillSource._item[_id]._sCurTimeIsLeft);
			TimeSpan pastTime 	= DateTime.Now  -  Convert.ToDateTime(SkillSource._item[_id]._sTimeIsClicked);
			_curTimeIsLeft 		= _timeCoolDown - pastTime.Seconds;

			SkillSource._item[_id]._sCurTimeIsLeft = Convert.ToString(_curTimeIsLeft);
			
			UpdateContent();
		}else{
			SkillSource._item[_id]._bOnUseSkill = false;
			_curTimeIsLeft 		= _timeCoolDown;
			_bIcon.enabled 		= true;
		}
	}
}

public void SetContent(int id)
{
	List<SkillContents> _item =  SkillSource._item;
	_id 			  = id;
	_type			  = _item[_id]._type;
	_curLevel 		  = _item[_id]._curLevel;
	_levelRequirement = _item[_id]._stageRequirement;
	_iSkill.SetSprite ( _item[_id]._spriteName);
	Utility.ChangeTextMesh(_tName		, _item[_id]._name);
	Utility.ChangeTextMesh(_tDescription, _item[_id]._description);

	UpdateContent(_id);
}

【Unity エラー】Inspecterでnullスクリプトがないか確認する

NullReferenceException: Object reference not set to an instance of an object
<原因>
Inspecterで、null(指定していない)スクリプトをコンポーネントに持つオブジェクトが存在する。

NullReferenceException: Object reference not set to an instance of an object
UnityEngine.UI.Graphic.OnRebuildRequested () (at /Users/builduser/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Graphic.cs:454)
UnityEngine.UI.GraphicRebuildTracker.OnRebuildRequested () (at /Users/builduser/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/GraphicRebuildTracker.cs:33)
UnityEngine.CanvasRenderer.RequestRefresh ()

answers.unity3d.com
answers.unity3d.com

アニメーションのプレイ "Animator.Play("stateName", layer, startFrame);"

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class AchievementNotif : MonoBehaviour {
	public AchievementContentNotif _achievementContentNotif;

	public Animator _animNotif;
	#region Event
	void OnEnable(){
		EventAchievementManager.onAchievementE += ShowNotif;
	}
	void OnDisable(){
		EventAchievementManager.onAchievementE -= ShowNotif;		
	}
	#endregion
	void ShowNotif (int i) {

		List<AchievementContents> _myCollection =  AchievementSource._instance._myCollection;
		_achievementContentNotif.SetContent(_myCollection[i]._name, 
		                                    _myCollection[i]._type, 
		                                    _myCollection[i]._goal);

		_animNotif.Play("PopNotif" , -1 , 0f);

	}

}

qiita.com