public TileElement(GameObject go, String type, String text) { this.type = type; this.text = text; this.tileElementGo = new GameObjectSerializable(go, go.name); if (type == "AdditionalElement") { this.mesh = new MeshSerializable(go.GetComponentInChildren <MeshFilter>().mesh); if (go.GetComponent <MeshRenderer>().material.color != null) { this.materialColorR = go.GetComponentInChildren <MeshRenderer>().material.color.r; this.materialColorG = go.GetComponentInChildren <MeshRenderer>().material.color.g; this.materialColorB = go.GetComponentInChildren <MeshRenderer>().material.color.b; } this.materialName = "TransparentGreyMaterial"; } else { this.mesh = new MeshSerializable(go.GetComponent <MeshFilter>().mesh); if (go.GetComponent <MeshRenderer>().material.color != null) { this.materialColorR = go.GetComponent <MeshRenderer>().material.color.r; this.materialColorG = go.GetComponent <MeshRenderer>().material.color.g; this.materialColorB = go.GetComponent <MeshRenderer>().material.color.b; } this.materialName = "BuildingsDefaultMat"; } }
public MapTile(GameObject tileGO) { this.tileGO = new GameObjectSerializable(tileGO, tileGO.name); this.mesh = new MeshSerializable(tileGO.GetComponent <MeshFilter>().mesh); this.materialName = "TerrainMaterial"; Texture2D texture = (Texture2D)tileGO.GetComponent <MeshRenderer>().material.mainTexture; this.textureData = texture.EncodeToPNG(); //File.WriteAllBytes("Serialized/" + "tile" + index + ".png", texture.EncodeToPNG()); }
public void TestGameObjectSerializable() { var go = new GameObjectSerializable { components = new [] { new ComponentUnion { camera = new CameraSerializable { backgroundColor = Color.red } } } }; var ser = new Serializer(); var res = ser.Serialize(go); var d = ser.Deserialize <GameObjectSerializable>(res); Assert.AreEqual(go.components[0].camera.backgroundColor, d.components[0].camera.backgroundColor); }
public TileElement(GameObject go, String type, Color color, String text) { this.type = type; this.text = text; this.tileElementGo = new GameObjectSerializable(go, go.name); this.mesh = new MeshSerializable(go.GetComponent <MeshFilter>().mesh); if (type.Equals("Road")) { this.materialName = "RoadsDefaultMaterial"; } else if (type.Equals("MapBuilding")) { this.materialName = "BuildingsDefaultMat"; } else { this.materialName = "TransparentGreyMaterial"; } this.materialColorR = color.r; this.materialColorG = color.g; this.materialColorB = color.b; }
public MapSerializable(GameObject mapGO) { this.mapGO = new GameObjectSerializable(mapGO, mapGO.name); }