unity

Unity Listからforeachを使ってremoveする

backham
foreach(Class item in Lists){ if(item.id == id){ Lists.remove(item); } } こんなかんじでやると、 InvalidOperationException: Collection was modified; enumeration operation may not execute. とエラーになるので、 List<Class> TmpList = Lists; foreach(Class item in Lists){ TmpList.Add(item ); } foreach(Class item in TmpList){ if(item.id == id){ Lists.remove(item); } } こうしてやる

Unity StreamingAssetsからファイルを読み出す

backham
Streaming Assets で iOSとAndroidの違いにハマったのでメモ。 string FilePath; #if UNITY_IPHONE FilePath = Application.dataPath + "/Raw/" + filename; #else string fullPath = "jar:file://" + Application.dataPath + "/!/assets/" + filename; WWW www = new WWW (fullPath); while (!www.isDone) { } FilePath = Application.persistentDataPath + filename; File.WriteAllBytes (toPath,www.bytes); #endif iOS

Unity の lookAt を おきかえる

backham
UnityのlookAtは便利ですが、回転をさらに細かく制御しようと思うと難しいので置き換えます。 Rot.transform.LookAt (Vector3.zero); こうするところを、 Vector3 relative = gameObject.transform.InverseTransformPoint(Vector3.zero);<br /> float angle = Mathf.Atan2(relative.x, relative.z)

Structure Sensor が届きました 、VR/ARもモバイルが本命という話

backham
<p style=" margin:8px 0 0 0; padding:0 4px;"> [Structure sensor きた!全く新しいVR/ARのプロダクト作る! #vr #ar #structuresensor](https://www.instagram.com/p/BNVcFAXAFsK/" style=" color:#000; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:normal; line-height:17px; text-decoration:none; word-wrap:break-word;) </p> <p style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; line-height:17px; margin-bottom:0; margin-top:8px; overflow:hidden; padding:8px 0 7px; text-align:center; text-overflow:ellipsis; white-space:nowrap;"> 正裕 黒川さん(@ma