1.在使用unity打开Windows文件时,会遇到unity程序最小化,此时需要在PlayerSetting里勾选Visible In Background 。
2. 使用ugui会遇到点击UI的时候穿透屏幕的情况,需要加上条件:
using UnityEngine.EventSystems;
if (EventSystem.current.IsPointerOverGameObject(0))
{
return;
}
else
{
Debug.Log("UI不会穿透");
}
3.
unity 带有RigidBody组件的物体禁止运动的方法:
Rigidbody rigidbody = transform.GetComponent<Rigidbody>(); rigidbody.velocity = Vector3.zero; rigidbody.constraints = RigidbodyConstraints.FreezeAll; rigidbody.constraints = RigidbodyConstraints.None;