public void DebugDumpVariables(bool verbose) { Debug.Log("============= Variable Mappings: "); foreach (Mapping mapping in Enum.GetValues(typeof(Mapping))) { DataVariable var = variableMappings[(int)mapping]; string label = var == null ? "unassigned" : var.Label; //Note - make this string separately instead of directly in the Debug.Log call below, or else seems to evaluate both options of the ? operator and then fails Debug.Log(Enum.GetName(typeof(Mapping), mapping) + ": " + label); } Debug.Log("------------------------------"); Debug.Log("Dumping data variable headers: "); foreach (DataVariable var in variables) { if (verbose) { var.DumpMetaData(); } else { Debug.Log("Label: " + var.Label); } if (verbose) { Debug.Log("------------------------------"); } } Debug.Log("=============================== end"); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.O)) { string[] paths = StandaloneFileBrowser.OpenFilePanel("Open File", "", "", true); foreach (string s in paths) { Debug.Log(s); } if (paths.Length == 0) { return; } bool success = false; string errorMsg = "Unknown Error"; //CSVReaderData data = new CSVReaderData(); DataVariable dataVariable = new DataVariable(); CSVReaderData dataObj = (CSVReaderData)dataVariable; // new CSVReaderData(); try { success = CSVReader.Read(paths[0], hasColumnsHeader, hasRowHeader, ref dataObj, out errorMsg); } catch (Exception e) { Debug.Log("Exception caugt: " + e.ToString()); return; } if (!success) { Debug.Log("Error msg from csv read: "); Debug.Log(errorMsg); } else { dataVariable.DumpMetaData(); dataVariable.DumpData(); dataVariable.Clear(); } } }