unity3d控制物体不出屏幕transform.position = new Vector3(Mathf.Clamp(this.width,Screen.width,0),0,0);transform.position = new Vector3(0,Mathf.Clamp(this.height,Screen.height,0),0);用来控制物体不出屏幕,把脚本赋给物体c#写的,
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/05 19:25:54
![unity3d控制物体不出屏幕transform.position = new Vector3(Mathf.Clamp(this.width,Screen.width,0),0,0);transform.position = new Vector3(0,Mathf.Clamp(this.height,Screen.height,0),0);用来控制物体不出屏幕,把脚本赋给物体c#写的,](/uploads/image/z/11138343-15-3.jpg?t=unity3d%E6%8E%A7%E5%88%B6%E7%89%A9%E4%BD%93%E4%B8%8D%E5%87%BA%E5%B1%8F%E5%B9%95transform.position+%3D+new+Vector3%28Mathf.Clamp%28this.width%2CScreen.width%2C0%29%2C0%2C0%29%3Btransform.position+%3D+new+Vector3%280%2CMathf.Clamp%28this.height%2CScreen.height%2C0%29%2C0%29%3B%E7%94%A8%E6%9D%A5%E6%8E%A7%E5%88%B6%E7%89%A9%E4%BD%93%E4%B8%8D%E5%87%BA%E5%B1%8F%E5%B9%95%2C%E6%8A%8A%E8%84%9A%E6%9C%AC%E8%B5%8B%E7%BB%99%E7%89%A9%E4%BD%93c%23%E5%86%99%E7%9A%84%2C)
unity3d控制物体不出屏幕transform.position = new Vector3(Mathf.Clamp(this.width,Screen.width,0),0,0);transform.position = new Vector3(0,Mathf.Clamp(this.height,Screen.height,0),0);用来控制物体不出屏幕,把脚本赋给物体c#写的,
unity3d控制物体不出屏幕
transform.position = new Vector3(Mathf.Clamp(this.width,Screen.width,0),0,0);
transform.position = new Vector3(0,Mathf.Clamp(this.height,Screen.height,0),0);
用来控制物体不出屏幕,把脚本赋给物体
c#写的,老报错,为啥呀
unity3d控制物体不出屏幕transform.position = new Vector3(Mathf.Clamp(this.width,Screen.width,0),0,0);transform.position = new Vector3(0,Mathf.Clamp(this.height,Screen.height,0),0);用来控制物体不出屏幕,把脚本赋给物体c#写的,
没有 width 和 height 这个参数.你要自己设置物体的高宽变量,然后再算位置!