• 9宫格设计 : 比如说4个角的图案固定,拉伸的时候不受影响
    [Unity3D]UI界面之瞄准镜设置说明

  • 通过设置 左上右下来:
    [Unity3D]UI界面之瞄准镜设置说明

  • 通过创建Image对象,将设置好的图片关联到Source Image
    [Unity3D]UI界面之瞄准镜设置说明

  • 调整瞄准镜跟随飞机, 注意这里设置的Z轴向量是0,这样能保证一直在视角前方

    		if (aimUI) {
    		Vector3 u = camUI.WorldToScreenPoint (transform.position + transform.forward * 9999);
    
    		aimUI.localPosition = new Vector3 (u.x- Screen.width * 0.5f, u.y - Screen.height * 0.5f, 0);;
    		//设置的x和y都要减去屏幕长宽的一半,是因为aimUI本身的对其方式就是基于父节点Canvas的中心点后再次居中,而不是基于整个Scene的中心点居中,所以要减去相应的数值
    	}
    

相关文章:

  • 2022-12-23
  • 2021-12-12
  • 2022-12-23
  • 2021-06-09
  • 2021-04-18
  • 2021-05-18
  • 2022-12-23
  • 2021-09-13
猜你喜欢
  • 2021-08-31
  • 2021-12-22
  • 2022-12-23
  • 2021-09-10
  • 2021-08-21
  • 2021-06-26
相关资源
相似解决方案