Unity3D 에서 plyerPrefs 를 관리 할수 있게 singleTon으로 따로 묶어서 관리 하기 위해서 만들었다~!

소스는 아래 참고 입니다.~


using UnityEngine;

using System.Collections;


public class CPlayerPrefs : MonoBehaviour {


    private static CPlayerPrefs _instance;  

    public static CPlayerPrefs Instance  

{   

get  

{   

            if (_instance == null)  

_instance = new CPlayerPrefs();

                return _instance;  

        }  

    }  

 

    

    public void OnApplicationQuit()

    {

        _instance = null;

    }

 

    public int _mNoticeVal;

 

    public int mNoticeVal

    {

        get

        {

if(PlayerPrefs.HasKey("NoticeVal")) {

                 _mNoticeVal = PlayerPrefs.GetInt("NoticeVal");

else {

_mNoticeVal = 0;

}

                return _mNoticeVal;

   }

   set

        {

            _mNoticeVal = value;

            PlayerPrefs.SetInt("NoticeVal", _mNoticeVal);

        }

    }

}

+ Recent posts