boolからintに変換する方法をメモ。
[ 方法 ]
「Convert.ToInt32(bool)」で変換できます。
[ 使用例 ]
下記はbool型のBoolTestをint型に変換しIntTestに代入しています。
using System.Collections; using System.Collections.Generic; using UnityEngine; using System; public class ScriptTest : MonoBehaviour { void Start() { bool BoolTest = false; int IntTest = Convert.ToInt32(BoolTest); } }
falseだと0でtrueだと1に変換されます。