Created
April 1, 2022 04:49
-
-
Save 314pies/6b8511f7e9582c8798286cd6818355e7 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; | |
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