Unity + NGUI开发2D游戏的笔记。

1、没法加Anchor

使用复制吧


2、多分辨率如何弄。(尤其差很远的情况下)

控制UIRoot的高,可以设置缩放


3、如何使得一个面板及其子都不可以有事件。

NGUITools.SetActive(this.transform.parent.gameObject, false);


4、算出实时屏幕宽高度

UIRoot uiroot = (UIRoot)GameObject.FindObjectOfType(typeof(UIRoot));
int height = uiroot.manualHeight;
int width = Mathf.CeilToInt(Screen.width * 1.0f / Screen.height * heightb);


5、鼠标位置,转成NGUI Plane空间。
Transform.InverseTransformPoint , TransformPoint正向,反向位置

1、没法加Anchor

使用复制吧

2、多分辨率如何弄。(尤其差很远的情况下)

控制UIRoot的高,可以设置缩放

3、如何使得一个面板及其子都不可以有事件。

NGUITools.SetActive(this.transform.parent.gameObject, false);

4、算出实时屏幕宽高度

UIRoot uiroot = (UIRoot)GameObject.FindObjectOfType(typeof(UIRoot));
int height = uiroot.manualHeight;
int width = Mathf.CeilToInt(Screen.width * 1.0f / Screen.height * heightb);

5、鼠标位置,转成NGUI Plane空间。
Transform.InverseTransformPoint , TransformPoint正向,反向位置

Plane.Raycast 光线投射

function Raycast (ray : Rayout enter : float) : bool

Description描述

Intersects a ray with the plane.

一条射线和平面相交。

This function sets enter to the distance along the ray, where it intersects the plane. If the ray is parallel to the plane, function returns false and sets enter to zero.

这个函数设置out enter沿着射线,相交平面的距离,如果该射线是平行于平面,函数返回false,并且设置out enter到0。

1、===========================================

没法加Anchor

使用复制吧


2、===========================================

多分辨率如何弄。(尤其差很远的情况下)

控制UIRoot的高,可以设置缩放


3、===========================================

如何使得一个面板及其子都不可以有事件。

NGUITools.SetActive(this.transform.parent.gameObject, false);


4、===========================================

算出实时屏幕宽高度

UIRoot uiroot = (UIRoot)GameObject.FindObjectOfType(typeof(UIRoot));
int height = uiroot.manualHeight;
int width = Mathf.CeilToInt(Screen.width * 1.0f / Screen.height * heightb);


5、===========================================
鼠标位置,转成NGUI Plane空间。
Transform.InverseTransformPoint ,
Transform.TransformPoint
正向,反向位置


// Create a plane
Transform trans = cachedTransform;
Plane plane = new Plane(trans.rotation * Vector3.back, trans.position);


// If the ray doesn't hit the plane, do nothing
float dist;
Ray ray = cachedCamera.ScreenPointToRay(screenPos);
if (!plane.Raycast(ray, out dist)) return;


// Transform the point from world space to local space
CenterOnPos(trans.InverseTransformPoint(ray.GetPoint(dist)));

6、====================================================

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值