Unity5.4.2f2、UGUI
1.创建一个Canvas。创建一个Image,用于放置背景图。
2.Image下面创建一个Camera,一个Render Texture,把这个Render Texture拖至Camera的Target Texture。
3.Image下面创建一个Raw Image,把Render Texture拖至Raw Image上。
层级结构:
Canvas
->Image
- ->Raw Image
- ->Camera
需求:播放的模型能够上下左右移动,放大缩小
左右移动
mCamera.transform.RotateAround(mRotatePoint.position,mCamera.transform.up,mRightSpeed * Input.GetAxis("Mouse X");
上下移动
mCamera.transform.RotateAround(mRotatePoint,position,mCamera.transform.right,mUpSpeed * Input.GetAxis("Mouse Y");
放大缩小
//里滑
if(Input.GetAxis("Mouse ScrollWheel") < 0)
{
if(mAnimationCamera.GetComponent<Camera>().fieldOfView <=100)
{
mAnimationCamera.GetComponent<Camera>().fieldOfView += 2;
}
if(mAnimationCamera.GetComponent<Camera>().orthographicSize <= 20)
{
mAnimationCamera.GetComponent<Camera>().orthographicSize += 0.5f;
}
}
//外滑
if(Input.GetAxis("Mouse ScrollWheel") > 0)
{
if (mAnimationCamera.GetComponent<Camera>().fieldOfView > 25)
{
mAnimationCamera.GetComponent<Camera>().fieldOfView -= 2;
}
if (mAnimationCamera.GetComponent<Camera>().orthographicSize >= 1)
{
mAnimationCamera.GetComponent<Camera>().orthographicSize -= 0.5f;
}
}