Skip to content

Instantly share code, notes, and snippets.

@314pies
Created April 1, 2022 04:49
Show Gist options
  • Save 314pies/6b8511f7e9582c8798286cd6818355e7 to your computer and use it in GitHub Desktop.
Save 314pies/6b8511f7e9582c8798286cd6818355e7 to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
[Serializable]
public class mazeCube
{
public int preFabType;
public Vector3 pos;
public Vector3 rotation;
}
[Serializable]
public class mazesData
{
public mazeCube[] datas;
}
public class JsonTest : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
mazeCube cube = new mazeCube();
cube.preFabType = 2;
cube.pos = Vector3.back;
mazesData mazeDatas = new mazesData();
mazeDatas.datas = new mazeCube[] { cube };
string json = JsonUtility.ToJson(mazeDatas);
print(json);
mazesData mazeDatas2= JsonUtility.FromJson<mazesData>(json);
}
// Update is called once per frame
void Update()
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment