资源简介
在这个脚本里,只要将代码里的Gameobject赋值给物体,就可以实现对模型的旋转、缩放等
代码片段和文件信息
using UnityEngine;
using System.Collections;
public class Radio_Operation1 : MonoBehaviour
{
#region//相关参数初始化
public Transform target;
public int MouseWheelSensitivity = 1;
private int MouseZoomMin = 1;
private int MouseZoomMax = 5;
private float normalDistance = 3;
private Vector3 normalized;
private float xSpeed = 250.0f;
private float ySpeed = 120.0f;
private int yMinLimit = -20;
private int yMaxLimit = 80;
private float x = 0.0f;
private float y = 0.0f;
private Vector3 screenPoint;
private Vector3 offset;
private Quaternion rotation = Quaternion.Euler(new Vector3(30f 0f 0f));
private Vector3 CameraTarget;
private GUIstyle style_opration = new GUIstyle();
public GUISkin CustomSkin;
private GUIstyle ziti = new GUIstyle();
//private Rect windowRect0 = new Rect(Screen.width * 11 / 35 Screen.height * 11 / 28 285 200);
private Rect windowRect0 = new Rect(0 0 285 200);
#endregion
#region//Start-初始化函数
void Start () {
CameraTarget = target.position;
float z = target.transform.position.z - normalDistance;
transform.position = rotation * new Vector3(transform.position.x transform.position.y z);
transform.LookAt(target);
var angles = transform.eulerAngles;
x = angles.y;
y = angles.x;
}
#endregion
#region//Updata-函数
void Update () {
if(Input.GetMouseButton(1))
{
x += Input.GetAxis(“Mouse X“) * xSpeed * 0.02f;
y -= Input.GetAxis(“Mouse Y“) * ySpeed * 0.02f;
y = ClampAngle(y yMinLimit yMaxLimit);
var rotation = Quaternion.Euler(y x 0);
var position = rotation * new Vector3(0.0f 0.0f -normalDistance) + CameraTarget;
transform.rotation = rotation;
transform.position = position;
}else if (Input.GetAxis(“Mouse ScrollWheel“) != 0)
{
normalized = (transform.position - CameraTarget).normalized;
if (normalDistance >= MouseZoomMin && normalDistance <= MouseZoomMax)
{
normalDistance -= Input.GetAxis(“Mouse ScrollWheel“) * MouseWheelSensitivity;
}
if (normalDistance < MouseZoomMin)
{
normalDistance = MouseZ
- 上一篇:C#进销存源码
- 下一篇:C#实验—接口:正方形、三角形、圆形求面积
相关资源
- unity3d实现物体透明渐变效果
- Q757416.zip VB.NET WinForms 如何让label中的
- 使用C#在Unity中制作VR游戏
- C# 数字图像处理,单色、Robers、Sobe
- VS2005中c#+opengl绘制立方体,圆锥体,
- Unity项目对齐地面功能
- Unity5实战使用C#和Unity开发多平台游戏
- C#版图像处理界面,包含二值化、灰度
- c#单击按钮、滑轮滚动放大、缩小pi
- C#Storyboard实现图片旋转
- 可视化调节曲线运动Unity插件
- u3d拖拽旋转缩放模型脚本
- SwitchClick.cs
- c# 排序算法诠释排序过程
- Unity\“I18N.West\“
- C#图片处理旋转拖动合并高仿QQ截图等
- c#开发,unity环境,计算器,支持四则
- unity3D简易计算器C#脚本代码
- LitJson.dll C# 与 unity 可用的Json处理插
- Unity3d使用Meth实现温度云图
- 简易unity屏幕特效代码shader+C#
- Unity不用Dll直接读取BMP图片并转为Te
- c# 图像 图像放大 图像放大缩小 以鼠
- C#画图软件
- C# 通过鼠标滚轮实现缩放图片和移动
- C#利用GDI+绘制旋转文字,矩形内可以
- Unity保存录音实际长度并分段上传服务
- c# 图片放大缩小鼠标点击放大区域为
- AssetStudio.v0.13.25 unity引擎解包工具
- Unity Excel插件 EPPlus 3.5+4.x
评论
共有 条评论