private void SaveSettingsValues()
        {
            if (!CheckAllSettingsValues())
            {
                return;
            }
            JumpCsvConfig jCsvConfig = null;

            if (!JumpCsvEditorHelper.ContainsJumpCsvAssetsFiles())  // if not found settings asset, create assets
            {
                jCsvConfig = JumpCsvConfig.CreateAsset();
            }
            else   // update value
            {
                jCsvConfig = JumpCsvConfig.GetAsset();
            }
            jCsvConfig.mCsvSpreadSheetFileDirectory = JumpCsvEditorHelper.MakeRelativePath(Application.dataPath, CsvSpreadSheetFileDirectory);
            jCsvConfig.mCsvSourceCodeFileDirectory  = JumpCsvEditorHelper.MakeRelativePath(Application.dataPath, CsvSourceCodeFileDirectory);
            jCsvConfig.mCsvBinDataDirectory         = JumpCsvEditorHelper.MakeRelativePath(Application.dataPath, CsvBinDataDirectory);
            jCsvConfig.mCsvDataClassPostfixName     = CsvDataClassPostfixName;
            jCsvConfig.mCsvDataClassPrefixName      = CsvDataClassPrefixName;
            jCsvConfig.mCsvDataStructPostfixName    = CsvDataStructPostfixName;
            jCsvConfig.mCsvDataStructPrefixName     = CsvDataStructPrefixName;
            jCsvConfig.mExcludeCsvFiles             = new List <string>(ExcludeCsvFiles.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
            jCsvConfig.mCsvExtensionNames           = new List <string>(CsvExtensionNames.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
            EditorUtility.SetDirty(jCsvConfig);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            AssetDatabase.ImportAsset("Assets/" + JumpCsvConfig.JumpCsvConfigAssetFile, ImportAssetOptions.ForceSynchronousImport);
            JumpCsvConfig.UpdateValue();
        }
Example #2
0
        public static string[] GetAllExpiredCsvFile()
        {
            List <string> expiredCsvFiles = new List <string>();

            foreach (string csvFile in ListAllCsvFilesInCsvFolder())
            {
                string csvCodeFileName = JumpCsvEditorHelper.PathCombine(JumpCsvEditorHelper.PathCombine(Application.dataPath, JumpCsvConfig.CsvSourceCodeFileDirectory), JumpCsvEditorHelper.GetCsvDataClassName(csvFile) + ".cs");
                //string csvDataFileName = JumpCsvEditorHelper.PathCombine(JumpCsvEditorHelper.PathCombine(Application.dataPath, JumpCsvConfig.CsvBinDataDirectory) , JumpCsvEditorHelper.GetCsvDataBinaryFileName(csvFile));
                if (!File.Exists(csvCodeFileName))
                {
                    expiredCsvFiles.Add(csvFile);
                }
                else   // check content is latest
                {
                    string className   = JumpCsvEditorHelper.GetCsvDataClassName(csvFile);
                    Type   csvCodeType = CsvHelper.GetType("JumpCSV." + className);
                    int    hashCode    = (int)(csvCodeType.GetField("mHashCode").GetValue(null));

                    string         resourcePath = JumpCsvEditorHelper.PathCombine(Application.dataPath, "Build/CSV/Common");
                    string         path         = JumpCsvEditorHelper.MakeRelativePath(resourcePath, csvFile);
                    CsvSpreadSheet spreadSheet  = new CsvSpreadSheet(path.Replace(".csv", ""), true);                      //string content = reader.ReadToEnd();
                    //csvReader.ReadFromString(content);
                    int CheckSum = spreadSheet.GetHashCode();
                    if (CheckSum != hashCode)
                    {
                        expiredCsvFiles.Add(csvFile);
                    }
                }
            }
            return(expiredCsvFiles.ToArray());
        }