Skip to content

Commit 03c053f

Browse files
committed
Initial Commit
0 parents  commit 03c053f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+10260
-0
lines changed

.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Unity
2+
[Ll]ibrary/
3+
[Tt]emp/
4+
[Oo]bj/
5+
[Bb]uild/
6+
[Bb]uilds/
7+
Assets/AssetStoreTools*
8+
9+
# Visual Studio cache directory
10+
.vs/
11+
12+
# Autogenerated VS/MD/Consulo solution and project files
13+
ExportedObj/
14+
.consulo/
15+
*.csproj
16+
*.unityproj
17+
*.sln
18+
*.suo
19+
*.tmp
20+
*.user
21+
*.userprefs
22+
*.pidb
23+
*.booproj
24+
*.svd
25+
*.pdb
26+
*.opendb
27+
28+
# Unity3D generated meta files
29+
*.pidb.meta
30+
*.pdb.meta
31+
32+
# Unity3D Generated File On Crash Reports
33+
sysinfo.txt
34+
35+
# Builds
36+
*.apk
37+
*.unitypackage
38+
39+
# For the mac guys
40+
*.DS_Store

JSONSerializerPlugin/.vsconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"version": "1.0",
3+
"components": [
4+
"Microsoft.VisualStudio.Workload.ManagedGame"
5+
]
6+
}

JSONSerializerPlugin/Assets/Code.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Programmer: Hunter Goodin
3+
* Date Created: 09/05/2022 @ 3:00 PM
4+
* Description: Reads a JSON file provided in editor
5+
*/
6+
7+
using UnityEngine;
8+
9+
public class JSONReader : MonoBehaviour
10+
{
11+
[Header("Files")]
12+
[SerializeField] TextAsset jsonFile;
13+
MyJSON myJSON;
14+
15+
[Header("Variables")]
16+
[SerializeField] bool myBool;
17+
[SerializeField] int myInt;
18+
[SerializeField] float myFloat;
19+
[SerializeField] string myStr;
20+
21+
[SerializeField] bool[] myBoolArr;
22+
[SerializeField] int[] myIntArr;
23+
[SerializeField] float[] myFloatArr;
24+
[SerializeField] string[] myStrArr;
25+
26+
void Start()
27+
{
28+
ParseJSON();
29+
}
30+
31+
void ParseJSON()
32+
{
33+
Debug.Log($"Parsing {jsonFile.name}.json\n{jsonFile.text}");
34+
35+
myJSON = JsonUtility.FromJson<MyJSON>(jsonFile.text);
36+
37+
myBool = myJSON.myBool;
38+
myInt = myJSON.myInt;
39+
myFloat = myJSON.myFloat;
40+
myStr = myJSON.myStr;
41+
42+
myBoolArr = myJSON.myBoolArr;
43+
myIntArr = myJSON.myIntArr;
44+
myFloatArr = myJSON.myFloatArr;
45+
myStrArr = myJSON.myStrArr;
46+
}
47+
}
48+
49+
//[System.Serializable]
50+
//public class MyJSON
51+
//{
52+
// public bool myBool;
53+
// public int myInt;
54+
// public float myFloat;
55+
// public string myStr;
56+
57+
// public bool[] myBoolArr;
58+
// public int[] myIntArr;
59+
// public float[] myFloatArr;
60+
// public string[] myStrArr;
61+
//}

JSONSerializerPlugin/Assets/Code/JSONReader.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Programmer: Hunter Goodin
3+
* Date Created: 09/05/2022 @ 3:00 PM
4+
* Description: Writes to a JSON file provided in editor
5+
*/
6+
7+
using System.IO;
8+
using UnityEditor;
9+
using UnityEngine;
10+
11+
public class JSONWriter : MonoBehaviour
12+
{
13+
[Header("Files")]
14+
[SerializeField] TextAsset jsonFile;
15+
16+
[Header("Variables")]
17+
[SerializeField] bool myBool;
18+
[SerializeField] int myInt;
19+
[SerializeField] float myFloat;
20+
[SerializeField] string myStr;
21+
22+
[SerializeField] bool[] myBoolArr;
23+
[SerializeField] int[] myIntArr;
24+
[SerializeField] float[] myFloatArr;
25+
[SerializeField] string[] myStrArr;
26+
27+
private void Start()
28+
{
29+
WriteToJSON();
30+
}
31+
32+
void WriteToJSON()
33+
{
34+
Debug.Log($"Writing to {jsonFile.name}.json");
35+
36+
MyJSON newJSON = new MyJSON(myBool, myInt, myFloat, myStr, myBoolArr, myIntArr, myFloatArr, myStrArr);
37+
string str = JsonUtility.ToJson(newJSON, true);
38+
39+
File.WriteAllText(AssetDatabase.GetAssetPath(jsonFile), str);
40+
EditorUtility.SetDirty(jsonFile);
41+
}
42+
}

JSONSerializerPlugin/Assets/Code/JSONWriter.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Programmer: Hunter Goodin
3+
* Date Created: 09/05/2022 @ 3:00 PM
4+
* Description: This class is the JSON object that gets written
5+
* It can also be included inside another class' file
6+
* (An example is commented out of JSONReader.cs)
7+
*/
8+
9+
// This class can also be written inside another class
10+
// An example is commented out of JSONReader.cs
11+
12+
[System.Serializable]
13+
public class MyJSON
14+
{
15+
public bool myBool;
16+
public int myInt;
17+
public float myFloat;
18+
public string myStr;
19+
20+
public bool[] myBoolArr;
21+
public int[] myIntArr;
22+
public float[] myFloatArr;
23+
public string[] myStrArr;
24+
25+
public MyJSON (bool myBool, int myInt, float myFloat, string myStr, bool[] myBoolArr, int[] myIntArr, float[] myFloatArr, string[] myStrArr)
26+
{
27+
this.myBool = myBool;
28+
this.myInt = myInt;
29+
this.myFloat = myFloat;
30+
this.myStr = myStr;
31+
32+
this.myBoolArr = myBoolArr;
33+
this.myIntArr = myIntArr;
34+
this.myFloatArr = myFloatArr;
35+
this.myStrArr = myStrArr;
36+
}
37+
}

JSONSerializerPlugin/Assets/Code/MyJSON.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

JSONSerializerPlugin/Assets/JSON Files.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)