public void Check() { if (sceneObjs.Count == 1) { GameObject composite = sceneObjs[0].gameObject; float compositeVolume = CSGUtil.VolumeOfMesh(composite); float targetVolume = CSGUtil.VolumeOfMesh(targetObj); //GameObject flagObj = Instantiate(composite) as GameObject; CSGUtil.Union(targetObj, composite); float unionVolume = CSGUtil.VolumeOfMesh(targetObj); //Debug.Log(unionVolume + " " + targetVolume + " " + compositeVolume); if ((unionVolume - targetVolume < 1e-3) && (unionVolume - compositeVolume < 1e-3)) { //Debug.Log(unionVolume + " " + targetVolume + " " + compositeVolume); //Debug.Log("You win...!!!"); CSGLog.Log(logPath, id, "Completed Level...!!!"); levelCompleteText.enabled = true; Destroy(composite); Destroy(targetObj); DataUtil.UnlockCurrentRoom(); return; } CSGLog.Log(logPath, id, "Check failed"); targetObj.GetComponent <MeshFilter>().sharedMesh = Instantiate(targetMesh) as Mesh; targetObj.GetComponent <MeshRenderer>().materials = new Material[] { targetMaterial }; targetObj.name = "Target"; } }
public void Union() { if (opA && opB) { CSGUtil.Union(opA.gameObject, opB.gameObject); sceneObjs.Remove(opB); Destroy(opB.gameObject); //Need to set to default because this is no longer opA opA.Init(); opA = null; opB = null; selectedObj.OnDeselect(); selectedObj = null; CSGLog.Log(logPath, id, "A+B"); } }