Skip to content

Instantly share code, notes, and snippets.

View PngConverter.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using MyLibrary;
namespace MagnaEngine
{
public static class PngConverter
{
View Test.cs
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Test : MonoBehaviour {
[System.Serializable]
public class Player{
[SerializeField]
public int hp;
public float atk;
View GameDataUser.cs
using UnityEngine;
using System.Collections;
public class GameDataUser : MonoBehaviour {
void Start () {
Debug.Log ("前回セーブしたPlayerのレベルは" + GameData.Player.Level);
GameData.Player.Level = 50;
GameData.Save ();
View GameData.cs
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class GameData : SingletonMonoBehaviour<GameData>{
//セーブしたいデータを定義するクラス
//コンストラクタで値を初期化
class SaveData: SavableSingleton<SaveData>{
public Player Player;
View SingletonMonoBehaviour.cs
using UnityEngine;
public class SingletonMonoBehaviour<T> : MonoBehaviour where T : MonoBehaviour
{
private static T instance;
public static T Instance {
get {
if (instance == null) {
instance = (T)FindObjectOfType(typeof(T));
View SavableSingleton.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using System.IO;
using System.Security.Cryptography;
abstract public class SavableSingleton<T> where T : SavableSingleton<T>, new()
{
View JsonMapper.cs
sing System;
using UnityEngine;
using System.Collections;
public class JsonMapper
{
static JsonMapper()
{
LitJson.JsonMapper.RegisterExporter<float>((obj, writer) => writer.Write(Convert.ToDouble(obj)));
LitJson.JsonMapper.RegisterExporter<decimal>((obj, writer) => writer.Write(Convert.ToString(obj)));
View Cript.cs
using System.IO;
using System.Security.Cryptography;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Crypt
{
private const string AesIV = @"jCddaOybW3zEh0Kl";
View SaveData.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using UnityEngine;
/// <summary>
/// Json形式でセーブできるクラスを提供します。
/// </summary>
You can’t perform that action at this time.