LoginSignup
0
0

More than 5 years have passed since last update.

Unity IL2CPP Il2CppCodeGenString から文字列を出力する

Last updated at Posted at 2017-07-25

結構、後ろ向きなテクニックでアレです。

動作確認環境

  • Xcode 8.3.3
  • Unity 2017.1.0f3

多分、Unity 5.5.x 以上なら動きます。

方法

文字列リテラルは、大抵の場合は __stringLiteralxxxx_ の様な変数名に格納されている。
型は Il2CppCodeGenString のポインタで定義されており、API として文字列長と最初のキャラクターのアドレスを取得する手段が設けられているので、最初のアドレスから文字数分イテレートを回してあげれば OK。
尚、下記サンプルはマルチバイトは考慮していません。

Il2CppChar* c = _stringLiteralxxxx->get_address_of_m_firstChar_1();
for (int i = 0; i < _stringLiteralxxxx->___m_stringLength_0; i++) {
    printf("%c", *(c+i));
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0