方向转为浮点数(来源:CodeMonkey插件) float GetAngleFromVectorFloat(Vector3 dir) { dir = dir.normalized; float n = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg; if (n < 0) n += 360; return n; //用法: tranform.eulerAngles=new vector3(0,0,GetAngleFromVectorFloat(dir))//用于朝着dir方向旋转