public static void CreateConfigFile(TMConfig.Config configToWrite) { var jsonString = JsonUtility.ToJson(configToWrite, true); var configPath = Path.Combine(Path.GetFullPath(Application.streamingAssetsPath), TMConfig.configFilename); Debug.Log("Saving JSON config file to " + configPath); if (File.Exists(configPath)) { File.Delete(configPath); } File.WriteAllText(configPath, jsonString); }
void OnGUI() { Vector2 pos = new Vector2(10, 70); if (showUI) { GUITools.Button(ref pos, "Hide UI", () => { showUI = false; }); GUITools.Button(ref pos, "Toggle Harpa model", () => { if (harpaModel != null) { harpaModel.SetActive(!harpaModel.activeSelf); } }); if (screensaver.isRendering) { GUITools.Button(ref pos, "Switch To Syphon", () => { screensaver.EndIdle(); }); } else { GUITools.Button(ref pos, "Switch To Screensaver", () => { screensaver.ShowIdle(); }); } GUITools.Button(ref pos, networkSendEnabled ? "Disable Network Send" : "Enable Network Send", () => { if (networkSendEnabled) { sender.enabled = false; } else { sender.enabled = true; sender.Init(renderServerIP, renderServerPort); } networkSendEnabled = !networkSendEnabled; }); if (networkSendEnabled) { GUITools.Label(ref pos, "Frames Sent : " + sender.framesSent); } GUITools.Button(ref pos, "Update All", () => { GetSyphonServerList(); UpdateSettings(); }); if (showSyphonSources) { GUITools.Button(ref pos, "Hide Syphon Sources", () => { showSyphonSources = false; }); pos += Vector2.right * 20; if (syphonServerList.Length == 0) { GUITools.Label(ref pos, "No Syphon Servers found"); } else { for (int i = 0; i < syphonServerList.Length; i++) { GUITools.Button(ref pos, syphonServerList[i] + "/" + syphonAppList[i], () => { Debug.Log("Switching Syphon input over to " + syphonAppList[i]); syphonClient.appName = syphonAppList[i]; }); } } pos -= Vector2.right * 20; } else { GUITools.Button(ref pos, "Show Syphon Sources", () => { showSyphonSources = true; }); } GUITools.Label(ref pos, "Render server IP"); renderServerIP = GUITools.TextField(ref pos, renderServerIP); renderServerPort = GUITools.TextField(ref pos, renderServerPort); GUITools.Button(ref pos, "Write Config", () => { TMConfig.Config newConfig = TMConfig.Current; newConfig.receiverIP = renderServerIP; newConfig.port = renderServerPort; TMEditorConfigurator.CreateConfigFile(newConfig); }); if (frameRate == updatedFrameRate) { GUITools.Label(ref pos, "Framerate : " + updatedFrameRate); } else { GUITools.Label(ref pos, "Framerate : " + frameRate + " : press update to change to " + updatedFrameRate); } updatedFrameRate = GUITools.IntSlider(ref pos, updatedFrameRate, 15, 50); } else { GUITools.Button(ref pos, "Show UI", () => { showUI = true; }); } }
public void OnValidate() { OverrideConfig = EditorOverrideConfig; DoConfigOverride = EditorDoConfigOverride; Debug.Log("Updating override config"); }