Change load addressable script
This commit is contained in:
@@ -18,6 +18,48 @@ namespace BrewMonster
|
||||
public CECStringTab() { }
|
||||
~CECStringTab() { Release(); }
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the table directly from a Unity TextAsset (e.g. loaded via Addressables).
|
||||
/// </summary>
|
||||
public bool InitFromTextAsset(TextAsset textAsset, bool bUnicode)
|
||||
{
|
||||
Release();
|
||||
m_bUnicode = bUnicode;
|
||||
|
||||
try
|
||||
{
|
||||
if (textAsset == null)
|
||||
{
|
||||
Debug.LogError("[CECStringTab] InitFromTextAsset failed: textAsset is null");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ok;
|
||||
if (bUnicode)
|
||||
{
|
||||
// Unity TextAsset.text is already UTF-8 decoded.
|
||||
using var sr = new StringReader(textAsset.text);
|
||||
ok = ParseIntoDict(sr, isWide: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// ANSI tables are in CP936 in original PW; keep using CP936 decoder.
|
||||
string content = ByteToStringUtils.ByteArrayToCP936String(textAsset.bytes);
|
||||
using var sr = new StringReader(content);
|
||||
ok = ParseIntoDict(sr, isWide: false);
|
||||
}
|
||||
|
||||
m_bInit = ok;
|
||||
return ok;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"[CECStringTab] InitFromTextAsset failed: {e}");
|
||||
Release();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Init(string szFile, bool bUnicode)
|
||||
{
|
||||
Release();
|
||||
|
||||
Reference in New Issue
Block a user