μΏ ν€λ° νΉλ€μ΄λ κΈ°ν λ€λ₯Έ λ°©μΉν κ²μλ€μμ λ³΄ν΅ μ μνλ μΌμ μκ°μ΄ μ§λλ©΄ 보μμ λ°μ μ μλ μμ€ν μ κ°λ°νκ³ μΆμλ€.
λ¬Όλ‘ μλ² μκ°μ κ°μ Έμ€λκ² λ² μ€νΈκ² μ§λ§ μΌλ¨μ λ΄μ₯λ μκ°μΌλ‘ ꡬνν΄λ³΄λ €κ³ νλ€.
λμ€μλ μ΄λ μλ² μκ°μ κ°μ Έμ¬ μ μλλ‘ λ³κ²½ν κ²μ΄λ€.
λ§μ½ νΈλν° μκ°μ κ°μ Έμ¬ κ²½μ° μ¬λλ€μ΄ μμλ‘ νΈλν° μκ°μ λ³κ²½νμ¬μ μ΄λμ μ·¨νλ ννκ° λ κ²μ΄λ€ - μλ₯Ό λ€μλ©΄ λν λ λμ²μ 무 μμ€ν κ°μ κ²½μ°
λμΆ© νν μμ€ν μ΄ μκ³ νν λ²νΌμ λλ₯΄λ©΄ λ΄κ° ννμ μμν μ€μ μκ°μ΄ μ μ₯λλλ‘ νλ €κ³ νλ€.
public void SaveExplore(float exploreHour, float exploreMinutes)
{
PlayerPrefs.SetFloat("exploreHour", exploreHour);
PlayerPrefs.SetFloat("exoloreMinutes", exploreMinutes);
}
νν λ²νΌμ΄ ν΄λ¦λλ©΄ μ΄λ¬ν λλμΌλ‘ μ λν°μ Player Preferenceμ μ μ₯μ ν΄μ€λ€.
PlayerPrefsλΌκ³ λΆλ₯΄λλ° μμΈν λ΄μ©μ docsλ₯Ό μ°Έκ³ ν΄λ³΄λ©΄ μ’μ κ² κ°λ€.
https://docs.unity3d.com/ScriptReference/PlayerPrefs.html
Unity - Scripting API: PlayerPrefs
Unity stores `PlayerPrefs` data differently based on which operating system the application runs on. In the file paths given on this page, the company name and product name are the names you set in Unity’s Player Settings. Standalone Player storage locat
docs.unity3d.com
μΌλ¨ UNITY EDITORμμμ νμ¬ μκ°μ λΆλ¬μλ³΄λ €κ³ νλ€.
Debug.Log(DateTime.Now.ToString()); //λ
,μ,μΌ,μ,λΆ,μ΄ νμ
Debug.Log(DateTime.Now.Year.ToString()); //λ
νμ
Debug.Log(DateTime.Now.Month.ToString()); //μ νμ
Debug.Log(DateTime.Now.Day.ToString()); //μΌ νμ
Debug.Log(DateTime.Now.Hour.ToString()); //μ νμ
Debug.Log(DateTime.Now.Minute.ToString()); //λΆ νμ
DateTime ν΄λμ€λ₯Ό μ΄μ©ν΄μ λΆλ¬μ€λλ‘ νκ³ λ§€νλ μλ§λ€ μ°λνλ건 μλκ² κ°μλ°..
μΌλ¨μ 맀νλ μ λ§λ€ μκ°μ λ°μμμ κ³μ°μ ν΄λ³΄λλ‘ νκ² λ€.
λ§μ½ λμ€μ νλ μ μ νκ° μΌμ΄λλ€λ©΄ λ€μ μμ ν΄μΌν κ²κ°λ€.
//νν μμ ν¨μλ₯Ό call ν μ ν΄λΉλλ ν¨μ call ννμ 보λ₯Ό λ°νν¨
//exploreKindNum : νν μ’
λ₯ λ²νΈ
public exploreInfo exploreStart(int exploreKindNum)
{
explInfo = new exploreInfo(DateTime.Now.Hour, DateTime.Now.Minute, costExplore[exploreKindNum]);
return explInfo;
}
//νν μμ
public void exploreStart(int exploreKindNum)
{
explInfo = exploreM.exploreStart(exploreKindNum);
//νν μμ μκ° μ μ₯(μΆ ν λ
λ μμΌκΉμ§ μ μ₯ν΄μ€μΌν¨)
saveM.SaveExplore(explInfo.hour, explInfo.minute, explInfo.costMinute, 1);
//UI 맀λμ μκ² ExploreGuage μ
λ°μ΄νΈ ν μ μλλ‘ μ΄κΈ°κ° λ£μ΄μ€
uiM.updateExploreGuage(explInfo);
}
κ·Έλ¦¬κ³ λ§μ½ ννμ€μ΄λΌλ©΄ UIλ₯Ό νν μ 보 κΈ°λ°μΌλ‘ κ³μ μ λ°μ΄νΈ ν΄μ€μΌνλ€.
//λ§μ½ ννμ΄ μμλμλ€λ©΄
if (explInfo.isExplore==1)
{
uiM.updateExploreGuage(explInfo);
}
public void updateExploreGuage(exploreInfo explInfo)
{
//λ¨μ μκ° κ³μ°
//μ΄ μκ°(λΆ)
float exploreTime = explInfo.hour * 60.0f + explInfo.minute;
float remainTime = (DateTime.Now.Hour - explInfo.hour) * 60.0f + (DateTime.Now.Minute - explInfo.minute);
explRemainTimeTxt.text = (explInfo.costMinute-remainTime).ToString()+"λΆ";
imgExploreGuage.fillAmount = remainTime / explInfo.costMinute;
}
μ΄λ κ² νλ©΄ μμ€ν λΆλ§λ€ νν κ²μ΄μ§κ° λ³κ²½λλ κ²μ νμΈν μ μλ€.
μ§κΈμ 5λΆ κΈ°μ€μΈλ° μ§κΈμ μ½λλ λΆλ¨μλ‘ μΆλ ₯λκ² λμ΄μμ΄μ ~μ~λΆμΌλ‘ μΆλ ₯λ μ μλλ‘ λ³κ²½ν΄μΌκ² λ€.
κ·Έλ¦¬κ³ λΆλ§λ€ μ λ°μ΄νΈ λλκ² λ³΄μ΄λλ° λ무 μ§λ£¨ν΄μ λ€λ₯Έ μμ€ν λ€ μ²λΌ μ΄λ§λ€ 보μ΄λ κ²μΌλ‘ λ³κ²½ν΄μΌκ² λ€.
λν μ§κΈμ μλμ° μμ€ν μκ°μ κ°μ Έμ€λλ° λ§μ½ μλλ‘μ΄λμ λ€μ΄κ°μ μκ°μ μ¬λ κ²½μ° λ€λ₯΄κ² μ¬μΌν μλ μκΈ° λλ¬Έμ(μλ² μκ°μ λΆλ¬μ€λκ² μ μΌ μ’μ λ― νλ€) μ’ λ μμ μ΄ νμν κ² κ°λ€.
λ§μ½ λ μΆκ°νκ² λλ€λ©΄ μΆ ν λΈλ‘κ·Έ κΈμ μμ 보μνλ €κ³ νλ€.
'κ²μμμ§ > Unity' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[Unity3D] LoadScene ν λ€ν¬λ λ¬Έμ ν΄κ²° λ°©λ² (0) | 2023.06.23 |
---|---|
[Unity3D] Spine νμΌ Unityλ μ°λνκΈ° (0) | 2022.01.24 |
C# μΌκ΄μ± μλ μ‘μΈμ€ κ°λ₯μ± λ§€κ° λ³μ νμμ΄ λ©μλλ³΄λ€ μ‘μΈμ€νκΈ° μ΄λ ΅μ΅λλ€ (0) | 2022.01.11 |
Unity Inspector μ°½μ public class κ°μ²΄ λνλλλ‘ νκΈ° (0) | 2020.06.05 |
Unity FBX Exporter μ€μΉνκΈ° (4) | 2020.06.02 |