Created
June 12, 2019 07:50
-
-
Save IshidaGames/06e927261de2a9c6a614f22de0783434 to your computer and use it in GitHub Desktop.
This file contains 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 System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class SavePos : MonoBehaviour | |
{ | |
ES3Settings settings; | |
GameObject player; | |
void Start() | |
{ | |
//変数に暗号の設定を入れる | |
settings = new ES3Settings(ES3.EncryptionType.AES, "password"); | |
//TagでPlayerを取得する | |
//複数だとGameObject[]でFindGameObjectsWithTag | |
player = GameObject.FindGameObjectWithTag("Player"); | |
//セーブファイルがあるかどうか | |
//keyの場合はES3.KeyExists | |
if (ES3.FileExists("SaveFile.es3", settings)) | |
{ | |
//ロード | |
player.transform.position = | |
ES3.Load<Vector3>("key", "SaveFile.es3", settings); | |
} | |
else | |
{ | |
Debug.Log("セーブファイルはありません"); | |
} | |
} | |
void Update() | |
{ | |
if (Input.GetMouseButton(0)) | |
{ | |
//セーブ | |
ES3.Save<Vector3>("key", player.transform.position, | |
"SaveFile.es3", settings); | |
} | |
if (Input.GetMouseButton(1)) | |
{ | |
//セーブファイルを消す | |
//keyごとだとES3.DeleteKey | |
ES3.DeleteFile("SaveFile.es3", settings); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment