LoginSignup
6
7

More than 5 years have passed since last update.

Unityからxcodeに書き出しアプリを実行したらdouble型の値が不正になってしまったケース

Posted at

アプリ開発で意外にハマってしまったのでメモ

開発環境

Unity 5.3.4
Xcode V7.2
実行端末 iphone6(64bit端末)

概要

Unityからxcodeに書き出しアプリを実行した。
「10.23456」の様な文字列をdouble型に変換したら
「2.00530492517596E-300」の様に非常に小さい値(不正な値)に
なってしまった。

さらにその値をfloat型の変数に変換(cast)したらNaNになってしまった。
その状態でTransform.localPosition
に代入したら、以下の様なエラーが発生した。

Infinity or NaN floating point numbers appear when calculating the transform matrix for a Collider.

原因

64bit端末に、32bit設定でビルドしたアプリを起動させたため。

現象発生時の手順
(1)UnityのIOSの書き出し設定
「Script Backend」を「Mono2x」にした。

(2)Xcodeに書き出す
Xcodeに書き出す

(3)xcodeでビルド
xcodeでビルドしてアプリを機動する。
その結果、「10.23456」の様な文字列がdouble型にしたら、
「2.00530492517596E-300」の様に非常に小さい値になってしまった。

解決手段

64bitの端末でアプリを動かすなら「Script Backend」を「LI2CPP」
32bitの端末でアプリを動かすなら「Script Backend」を「Mono2x」
にする。

端末に関して役立つ情報があったので記載
iOS デバイス一覧表

6
7
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
6
7