public void SaveToJSON(string file) { JArray jArray = new JArray(); foreach (LumarcaFrame frame in frames) { JArray jsonFrame = frame.GetJSONLine(); jArray.Add(jsonFrame); } string jStr = JsonConvert.SerializeObject(jArray, Formatting.Indented); string exportPath = Application.dataPath + "/" + file + "-anim.json"; UtilScript.SaveStringToFile(exportPath, jStr); }
void Update() { // print("lefts" + lefts.Count); // print("rights" + rights.Count); if (Input.GetKeyDown(KeyCode.K)) { print("K: " + indexCallOut); if (LoadLumarca.killStringsList.Contains(indexCallOut)) { print("has"); LoadLumarca.killStringsList.Remove(indexCallOut); } else { print("hasnot"); LoadLumarca.killStringsList.Add(indexCallOut); } string result = ""; string resultDiplay = ""; int count = 0; for (int i = 0; i < LoadLumarca.killStringsList.Count; i++) { int num = LoadLumarca.killStringsList[i]; while (LoadLumarca.killStringsList.Contains(num)) { LoadLumarca.killStringsList.Remove(num); } LoadLumarca.killStringsList.Add(num); } for (int i = 0; i < LoadLumarca.killStringsList.Count; i++) { result += LoadLumarca.killStringsList[i] + ","; resultDiplay += LoadLumarca.killStringsList[i] + ","; count++; if (count == 30) { count = 0; resultDiplay += "\n"; } } //550, 502, 454 PlayerPrefs.SetString(LoadLumarca.PP_KILL_STRING, result); UtilScript.SaveStringToFile("KillStrings.txt", result); killDisplay.text = "Kill String: " + resultDiplay; print("Kill String: " + result); } if (Input.GetKeyDown(KeyCode.Return)) { print(callString); if (!callString.Equals("")) { int i = System.Int32.Parse(callString); if (i >= 0 || i < 640) { indexCallOut = i; upCall = true; } callString = ""; } } else { InputKey(KeyCode.Keypad0, 256); InputKey(KeyCode.Keypad1, 256); InputKey(KeyCode.Keypad2, 256); InputKey(KeyCode.Keypad3, 256); InputKey(KeyCode.Keypad4, 256); InputKey(KeyCode.Keypad5, 256); InputKey(KeyCode.Keypad6, 256); InputKey(KeyCode.Keypad7, 256); InputKey(KeyCode.Keypad8, 256); InputKey(KeyCode.Keypad9, 256); InputKey(KeyCode.Alpha0, 48); InputKey(KeyCode.Alpha1, 48); InputKey(KeyCode.Alpha2, 48); InputKey(KeyCode.Alpha3, 48); InputKey(KeyCode.Alpha4, 48); InputKey(KeyCode.Alpha5, 48); InputKey(KeyCode.Alpha6, 48); InputKey(KeyCode.Alpha7, 48); InputKey(KeyCode.Alpha8, 48); InputKey(KeyCode.Alpha9, 48); } if (Input.GetKeyDown(KeyCode.Space)) { calMode = !calMode; } if (lefts.Count > 0 && rights.Count > 0) { if (Input.GetKeyDown(KeyCode.Q)) { indexLeft++; } else if (Input.GetKeyDown(KeyCode.A)) { indexLeft--; } if (indexLeft < 0) { indexLeft = lefts.Count - 1; } if (Input.GetKeyDown(KeyCode.O)) { indexRight++; } else if (Input.GetKeyDown(KeyCode.L)) { indexRight--; } if (indexRight < 0) { indexRight = rights.Count - 1; // indexRight = lefts.Count - 1; } lineLeftNum = lefts[indexLeft % lefts.Count]; lineRightNum = rights[indexRight % rights.Count]; // lineRightNum = lefts[indexRight%lefts.Count]; } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space)) { // if(Input.mousePosition.x > 300 && !once){ once = true; Debug.Log("tolerance: " + tolerance); Debug.Log("End count:" + lines.Count); part1 = !part1; SetColorToPart(); int part = 2; if (part1) { part = 1; } StartCoroutine(UploadPNG(fileNamePre + "Lumarca" + Camera.main.pixelWidth + "x" + Camera.main.pixelHeight + "_DotSize" + yarnWidth + "Depth" + numDepths + "Part" + part)); BinaryWriter writer; StringReader reader; switch (lumarcaMode) { case LUMARCA_MODE.VLines: JObject jObject = new JObject(); jObject[PROP_LUMARCA_SIZE] = cfs.physicalWidth; jObject[PROP_PROJ_POS] = UtilScript.Vector3ToJson(cfs.transform.position); jObject[PROP_THROW_RATIO] = cfs.throwRatio; jObject[PROP_PHYSICAL_WIDTH] = cfs.physicalWidth; jObject[PROP_CEILING_MOUNT] = cfs.ceilingMounted; JArray jPositions = new JArray(); jObject[PROP_POSITIONS] = jPositions; for (int i = 0; i < lines.Count; i++) { jPositions.Add(UtilScript.Vector3ToJson(lines[i])); } string positionFile = System.IO.Path.Combine(Application.dataPath, fileNamePre + "-positions.json"); writer = new BinaryWriter(File.Open(positionFile, FileMode.Create)); string objStr = JsonConvert.SerializeObject(jObject, Formatting.Indented); writer.Write(objStr); writer.Close(); string exportPath = Application.dataPath + "/" + fileNamePre + "-" + cfs.physicalWidth + "-export.json"; UtilScript.SaveStringToFile(exportPath, objStr); JObject o1 = JObject.Parse(File.ReadAllText(exportPath)); Debug.Log("Save File: " + positionFile); Debug.Log("exportPath File: " + exportPath); Debug.Log("Vec3: " + o1["ThrowRatio"]); break; case LUMARCA_MODE.Dots: // for(int i = 0; i < dots.Count; i++){ // jPositions[i] = UtilScript.Vector3ToJson(dots[i]); // } // // string dotFile = System.IO.Path.Combine(Application.dataPath, "DotPositions.json"); // // writer = new BinaryWriter(File.Open(dotFile, FileMode.Create)); // jPositions.Serialize(writer); // writer.Close(); // // reader = new BinaryReader(File.Open(dotFile, FileMode.Open)); // ja = SimpleJSON.JSONNode.Deserialize(reader); // // reader.Close(); // // // for(int i = 0; i < ja.Count; i++){ // Debug.Log ("jn: " + i + " : " + JSON.Parse(ja[i])["x"]); // } break; } } // DrawBox(); }