Skip to content

Instantly share code, notes, and snippets.

@IshidaGames
Created June 12, 2019 07:50
Show Gist options
  • Save IshidaGames/06e927261de2a9c6a614f22de0783434 to your computer and use it in GitHub Desktop.
Save IshidaGames/06e927261de2a9c6a614f22de0783434 to your computer and use it in GitHub Desktop.
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