物体随着鼠标的移动而移动的脚本:
using UnityEngine;
using System.Collections;
public class HatController : MonoBehaviour {
//实例化的对象.
public GameObject effect;
private Vector3 rawPosition;
private Vector3 hatPosition;
private float maxWidth;
// Use this for initialization
void Start () {
//将屏幕的宽度转换成世界坐标.
Vector3 screenPos = new Vector3(Screen.width,0,0);
Vector3 moveWidth=Camera.main.ScreenToWorldPoint(screenPos);
//计算帽子的宽度.
float hatWidth=