使用位运算,直接上代码
public void IntToBoolArray() { bool[] bArray = new bool[32]; int inputNum = 3; int endNum; for(int i= 0;i<32;i++) { endNum = 1 << i; if(endNum == (endNum & inputNum)) { bArray[i] = true; }else { bArray[i] = false; } Debug.Log(bArray[i]); } }