Exemplo n.º 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]));
        }
Exemplo n.º 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]));
        }
Exemplo n.º 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) { }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Load or Create Scriptable Object
        /// </summary>
        /// <returns></returns>
        public static WindowCSVData LoadData()
        {
            //try get scriptable object (data)
            WindowCSVData data = AssetDatabase.LoadAssetAtPath <WindowCSVData>(GetDataPath());

            //if there is no data, create it
            if (data == null)
            {
                data = CreateInstance <WindowCSVData>();
                data.StructCSV.Add(new WindowCSVStruct());          //create first element in the list
                AssetDatabase.CreateAsset(data, GetDataPath());
            }

            //load data
            return(data);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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();
        }
Exemplo n.º 9
0
 void OnEnable()
 {
     //load data
     data = WindowCSVData.LoadData();
 }