コード例 #1
0
        /// <summary>
        /// Load File from folder using index
        /// </summary>
        public static string LoadFile(int structIndex)
        {
            //load data
            WindowCSVData data = WindowCSVData.LoadData();

            //load file using index
            return(LoadFile(data.StructCSV[structIndex]));
        }
コード例 #2
0
        /// <summary>
        /// Load File from folder using selected one in the window
        /// </summary>
        public static string LoadFile()
        {
            //load data
            WindowCSVData data = WindowCSVData.LoadData();

            //load file using index in data
            return(LoadFile(data.StructCSV[data.IndexStruct]));
        }
コード例 #3
0
        /// <summary>
        /// Start Download from link
        /// </summary>
        public static void DownloadCSV()
        {
            //load data
            WindowCSVData data = WindowCSVData.LoadData();

            //UnityWebRequest replace old WWW
            www = UnityWebRequest.Get(data.StructCSV[data.IndexStruct].LinkCSV);
            UnityWebRequestAsyncOperation request = www.SendWebRequest();

            //wait download
            request.completed += OnCompleteDownload;

            //while (!request.isDone) { }
        }
コード例 #4
0
        /// <summary>
        /// Delete directory with every file
        /// </summary>
        public static void DeleteDirectory()
        {
            //load data
            WindowCSVData data = WindowCSVData.LoadData();

            //check there is a directory
            if (Directory.Exists(data.StructCSV[data.IndexStruct].PathFolder) == false)
            {
                Debug.Log("Directory not found: " + data.StructCSV[data.IndexStruct].PathFolder);
                return;
            }

            //delete directory
            Directory.Delete(data.StructCSV[data.IndexStruct].PathFolder, true);
            Debug.Log("Directory deleted successfully: " + data.StructCSV[data.IndexStruct].PathFolder);
        }
コード例 #5
0
        /// <summary>
        /// Delete file
        /// </summary>
        public static void DeleteFile()
        {
            //load data
            WindowCSVData data = WindowCSVData.LoadData();

            //check there is a file
            if (File.Exists(data.StructCSV[data.IndexStruct].PathFile) == false)
            {
                Debug.Log("File not found: " + data.StructCSV[data.IndexStruct].PathFile);
                return;
            }

            //delete file
            File.Delete(data.StructCSV[data.IndexStruct].PathFile);
            Debug.Log("File deleted successfully: " + data.StructCSV[data.IndexStruct].PathFile);
        }
コード例 #6
0
        /// <summary>
        /// Load File from folder looking in the list using StructName
        /// </summary>
        public static string LoadFile(string structName)
        {
            //load data
            WindowCSVData data = WindowCSVData.LoadData();

            foreach (WindowCSVStruct structCSV in data.StructCSV)
            {
                //if found name
                if (structCSV.StructName.Equals(structName))
                {
                    return(LoadFile(structCSV));
                }
            }

            return(null);
        }
コード例 #7
0
        /// <summary>
        /// Save downloaded File in folder
        /// </summary>
        /// <param name="value"></param>
        public static void SaveFile(string value)
        {
            //load data
            WindowCSVData data = WindowCSVData.LoadData();

            //if there is no directory, create it
            if (Directory.Exists(data.StructCSV[data.IndexStruct].PathFolder) == false)
            {
                Directory.CreateDirectory(data.StructCSV[data.IndexStruct].PathFolder);
            }

            //create stream to file position
            StreamWriter writer = new StreamWriter(data.StructCSV[data.IndexStruct].PathFile);

            //then save value to file position, and close stream
            writer.Write(value);
            writer.Close();
        }
コード例 #8
0
 void OnEnable()
 {
     //load data
     data = WindowCSVData.LoadData();
 }