Beispiel #1
0
////////////////////////////////////////////////////////////////////////////////////////////
        // Loads a file using a path
        private void LoadFileUsingPath(string path)
        {
            if (path.Length != 0)
            {
                if (datasetsPanel.activeInHierarchy)
                {
                    string readText = File.ReadAllText(path);
                    setsStorage.data = readText;
                    //storage.ExtractNInstantiate();
                    setsStorage.CreateDataset(path);
                }
                else if (colormapsPanel.activeInHierarchy)
                {
                    string readText = File.ReadAllText(path);
                    uiStorage.AddColormap(readText);
                }
                // sinon, on est dans le cas du chargement d'un fichier de sauvegarde
                else
                {
                    BinaryFormatter bFormatter = new BinaryFormatter();
                    // Open the file using the path
                    FileStream file = File.OpenRead(path);
                    // Convert the file from a byte array into a string
                    string fileData = bFormatter.Deserialize(file) as string;
                    // We're done working with the file so we can close it
                    file.Close();
                    // send it to the save parser
                    savesManager.UnpackData(fileData);

                    // Set the LoadedText with the value of the file
                    //_loadedText.GetComponent<Text>().text = "Loaded data: \n" + fileData;
                }
            }
            else
            {
                Debug.Log("Invalid path given");
            }
        }