本文整理汇总了C#中ByteReader.ReadCSV方法的典型用法代码示例。如果您正苦于以下问题:C# ByteReader.ReadCSV方法的具体用法?C# ByteReader.ReadCSV怎么用?C# ByteReader.ReadCSV使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ByteReader
的用法示例。
在下文中一共展示了ByteReader.ReadCSV方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadCSV
/// <summary>
/// Load the specified CSV file.
/// </summary>
static public bool LoadCSV (TextAsset asset)
{
#if SHOW_REPORT
mUsed.Clear();
#endif
ByteReader reader = new ByteReader(asset);
// The first line should contain "KEY", followed by languages.
BetterList<string> temp = reader.ReadCSV();
// There must be at least two columns in a valid CSV file
if (temp.size < 2) return false;
// The first entry must be 'KEY', capitalized
temp[0] = "KEY";
#if !UNITY_3_5
// Ensure that the first value is what we expect
if (!string.Equals(temp[0], "KEY"))
{
Debug.LogError("Invalid localization CSV file. The first value is expected to be 'KEY', followed by language columns.\n" +
"Instead found '" + temp[0] + "'", asset);
return false;
}
else
#endif
{
knownLanguages = new string[temp.size - 1];
for (int i = 0; i < knownLanguages.Length; ++i)
knownLanguages[i] = temp[i + 1];
}
mDictionary.Clear();
// Read the entire CSV file into memory
while (temp != null)
{
AddCSV(temp);
temp = reader.ReadCSV();
}
return true;
}
示例2: LoadCSV
/// <summary>
/// Load the specified CSV file.
/// </summary>
static bool LoadCSV (byte[] bytes, TextAsset asset, bool merge = false)
{
if (bytes == null) return false;
ByteReader reader = new ByteReader(bytes);
// The first line should contain "KEY", followed by languages.
BetterList<string> temp = reader.ReadCSV();
// There must be at least two columns in a valid CSV file
if (temp.size < 2) return false;
// Clear the dictionary
if (!merge || temp.size - 1 != mLanguage.Length)
{
merge = false;
mDictionary.Clear();
}
temp[0] = "KEY";
mLanguages = new string[temp.size - 1];
for (int i = 0; i < mLanguages.Length; ++i)
mLanguages[i] = temp[i + 1];
// Read the entire CSV file into memory
while (temp != null)
{
AddCSV(temp, !merge);
temp = reader.ReadCSV();
}
return true;
}
示例3: LoadCSV
/// <summary>
/// Load the specified CSV file.
/// </summary>
static bool LoadCSV (byte[] bytes, TextAsset asset, bool merge = false)
{
if (bytes == null) return false;
ByteReader reader = new ByteReader(bytes);
// The first line should contain "KEY", followed by languages.
BetterList<string> header = reader.ReadCSV();
// There must be at least two columns in a valid CSV file
if (header.size < 2) return false;
header.RemoveAt(0);
string[] languagesToAdd = null;
if (string.IsNullOrEmpty(mLanguage)) localizationHasBeenSet = false;
// Clear the dictionary
if (!localizationHasBeenSet || (!merge && !mMerging) || mLanguages == null || mLanguages.Length == 0)
{
mDictionary.Clear();
mLanguages = new string[header.size];
if (!localizationHasBeenSet)
{
mLanguage = PlayerPrefs.GetString("Language", header[0]);
localizationHasBeenSet = true;
}
for (int i = 0; i < header.size; ++i)
{
mLanguages[i] = header[i];
if (mLanguages[i] == mLanguage)
mLanguageIndex = i;
}
}
else
{
languagesToAdd = new string[header.size];
for (int i = 0; i < header.size; ++i) languagesToAdd[i] = header[i];
// Automatically resize the existing languages and add the new language to the mix
for (int i = 0; i < header.size; ++i)
{
if (!HasLanguage(header[i]))
{
int newSize = mLanguages.Length + 1;
#if UNITY_FLASH
string[] temp = new string[newSize];
for (int b = 0, bmax = arr.Length; b < bmax; ++b) temp[b] = mLanguages[b];
mLanguages = temp;
#else
System.Array.Resize(ref mLanguages, newSize);
#endif
mLanguages[newSize - 1] = header[i];
Dictionary<string, string[]> newDict = new Dictionary<string, string[]>();
foreach (KeyValuePair<string, string[]> pair in mDictionary)
{
string[] arr = pair.Value;
#if UNITY_FLASH
temp = new string[newSize];
for (int b = 0, bmax = arr.Length; b < bmax; ++b) temp[b] = arr[b];
arr = temp;
#else
System.Array.Resize(ref arr, newSize);
#endif
arr[newSize - 1] = arr[0];
newDict.Add(pair.Key, arr);
}
mDictionary = newDict;
}
}
}
Dictionary<string, int> languageIndices = new Dictionary<string, int>();
for (int i = 0; i < mLanguages.Length; ++i)
languageIndices.Add(mLanguages[i], i);
// Read the entire CSV file into memory
for (;;)
{
BetterList<string> temp = reader.ReadCSV();
if (temp == null || temp.size == 0) break;
if (string.IsNullOrEmpty(temp[0])) continue;
AddCSV(temp, languagesToAdd, languageIndices);
}
if (!mMerging && onLocalize != null)
{
mMerging = true;
OnLocalizeNotification note = onLocalize;
onLocalize = null;
note();
onLocalize = note;
mMerging = false;
}
//.........这里部分代码省略.........
示例4: LoadCSV
private static bool LoadCSV(byte[] bytes, TextAsset asset, bool merge = false)
{
if (bytes == null)
{
return false;
}
ByteReader byteReader = new ByteReader(bytes);
BetterList<string> betterList = byteReader.ReadCSV();
if (betterList.size < 2)
{
return false;
}
if (!merge || betterList.size - 1 != Localization.mLanguage.Length)
{
merge = false;
Localization.mDictionary.Clear();
}
betterList[0] = "KEY";
Localization.mLanguages = new string[betterList.size - 1];
for (int i = 0; i < Localization.mLanguages.Length; i++)
{
Localization.mLanguages[i] = betterList[i + 1];
}
while (betterList != null)
{
Localization.AddCSV(betterList, !merge);
betterList = byteReader.ReadCSV();
}
return true;
}