facebook twitter hatena line email

「Unity/Csharp/Ini」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(iniファイル呼び出し)
行9: 行9:
 
if (!System.IO.File.Exists(configPath))
 
if (!System.IO.File.Exists(configPath))
 
{
 
{
 +
    Debug.LogError("not file");
 
     return;
 
     return;
 
}
 
}
 
IniFileReader reader = new IniFileReader(configPath);
 
IniFileReader reader = new IniFileReader(configPath);
 
reader.SetSection("section1");
 
reader.SetSection("section1");
 +
if (value == null)
 +
{
 +
    Debug.LogError("key=null");
 +
    return;
 +
}
 
string path = reader.GetValue("key1");
 
string path = reader.GetValue("key1");
 
</pre>
 
</pre>

2021年8月31日 (火) 19:27時点における版

Ini読み込みサンプル

プラグインを使わないタイプ

http://tech.hikware.com/article/20170817a.html

iniファイル呼び出し

string configPath = System.IO.Directory.GetCurrentDirectory() + Const.CONFIG_PATH;
if (!System.IO.File.Exists(configPath))
{
    Debug.LogError("not file");
    return;
}
IniFileReader reader = new IniFileReader(configPath);
reader.SetSection("section1");
if (value == null)
{
    Debug.LogError("key=null");
    return;
}
string path = reader.GetValue("key1");