public Dictionary <string, CameraPositionAndMessage> LoadCameraDictionaryFile(string fileName) { Dictionary <string, CameraPositionAndMessage> cameraPositionAndMessageDictionary = new Dictionary <string, CameraPositionAndMessage>(); string filetext = File.ReadAllText(UserData.Path + "cameramessage/" + fileName + ".csv"); string[] cameraMessageArray = filetext.Split('\n'); foreach (string cameraMessage in cameraMessageArray) { string[] cameraSetting = cameraMessage.Trim().Split(';'); /// csv structure: /// string CameraName (C1, C2 etc.) /// Vector3 TargetPos /// Vector3 CameraDir /// Vector3 CameraAngle /// float CameraFov /// string Text if (cameraSetting.Length >= 6) { string cameraName = cameraSetting[0]; Vector3 targetPos = StringToVector3(cameraSetting[1]); Vector3 cameraDir = StringToVector3(cameraSetting[2]); Vector3 cameraAngle = StringToVector3(cameraSetting[3]); float cameraFov = 0f; float.TryParse(cameraSetting[4], out cameraFov); string message = cameraSetting[5]; // we have to encode newline, otherwise it messes with the CSV string decodedText = message.Replace('§', '\n'); CameraPositionAndMessage cameraPositionAndMessage = new CameraPositionAndMessage(decodedText, targetPos, cameraDir, cameraAngle, cameraFov); cameraPositionAndMessageDictionary.Add(cameraName, cameraPositionAndMessage); } } return(cameraPositionAndMessageDictionary); }
private void ShowCameraMenu() { GUILayout.BeginArea(new Rect((float)(Screen.width / 3), (float)(Screen.height / 3), (float)(Screen.width / 3), (float)(Screen.height / 2))); GUILayout.BeginVertical(new GUILayoutOption[0]); if (GUILayout.Button("Edit Text and save camera position")) { //Console.WriteLine("Edit Text of " + lastButtonPressed + " was requested."); ToggleCameraMenu(); if (cameraDictionary.ContainsKey(lastButtonPressed)) { messageTextToEdit = cameraDictionary[lastButtonPressed].Text; } ToggleTextEditor(); } if (GUILayout.Button("Save Camera position")) { //Console.WriteLine("Save Camera position of " + lastButtonPressed + " was requested."); showCameraMenu = false; if (cameraDictionary.ContainsKey(lastButtonPressed)) { messageTextToEdit = cameraDictionary[lastButtonPressed].Text; cameraDictionary.Remove(lastButtonPressed); } else { messageTextToEdit = string.Empty; } Vector3 cameraDistance = new Vector3(studioneocam.Export().distance.x, studioneocam.Export().distance.y, studioneocam.Export().distance.z); cameraDictionary.Add(lastButtonPressed, new CameraPositionAndMessage(messageTextToEdit, studioneocam.targetPos, cameraDistance, studioneocam.cameraAngle, studioneocam.fieldOfView)); } if (GUILayout.Button("Remove all camera settings")) { cameraDictionary.Remove(lastButtonPressed); } if (GUILayout.Button("Copy camera settings to clipboard")) { Vector3 cameraDistance = new Vector3(studioneocam.Export().distance.x, studioneocam.Export().distance.y, studioneocam.Export().distance.z); clipboardCamera = cameraDictionary[lastButtonPressed]; ToggleCameraMenu(); } if (GUILayout.Button("Paste camera settings from clipboard")) { if (cameraDictionary.ContainsKey(lastButtonPressed)) { cameraDictionary.Remove(lastButtonPressed); } cameraDictionary.Add(lastButtonPressed, clipboardCamera); ToggleCameraMenu(); } if (GUILayout.Button("Cancel")) { //Console.WriteLine("Cancelled menu."); ToggleCameraMenu(); } GUILayout.EndVertical(); GUILayout.EndArea(); }