Finalised json save, added newtonsoft to project, v1.3.0
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using Assets.Scripts;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public class NoiseGenerator
|
||||
{
|
||||
@@ -227,4 +229,31 @@ public class NoiseGenerator
|
||||
mesh.colors32 = colors;
|
||||
tile.GetComponent<MeshCollider>().sharedMesh = mesh;
|
||||
}
|
||||
|
||||
public string saveTile(GameObject tile)
|
||||
{
|
||||
string result = "";
|
||||
Vector3[] vertices = tile.GetComponent<MeshFilter>().mesh.vertices;
|
||||
Color32[] colors = tile.GetComponent<MeshFilter>().mesh.colors32;
|
||||
result = result + "\"vertices\": {\r\n";
|
||||
for (int i = 0; i < vertices.Length; i++)
|
||||
{
|
||||
result = result + FileHandler.generateJSON("vertice"+i, "\"" + vertices[i].x + "/" + vertices[i].y + "/" + vertices[i].z + "\"");
|
||||
if (i < vertices.Length - 1)
|
||||
{
|
||||
result = result + ",\r\n";
|
||||
}
|
||||
}
|
||||
result = result + "\r\n},\"colors\": {\r\n";
|
||||
for (int i = 0; i < colors.Length; i++)
|
||||
{
|
||||
result = result + FileHandler.generateJSON("color" + i, "\"" + colors[i].r + "/" + colors[i].g + "/" + colors[i].b + "\"");
|
||||
if (i < colors.Length - 1)
|
||||
{
|
||||
result = result + ",\r\n";
|
||||
}
|
||||
}
|
||||
result = result + "\r\n}";
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user