http://v.youku.com/v_show/id_XMTc2MzE3NDU4MA==.html?from=y1.7-2(视频地址)
代码:
using UnityEngine;
using System.Collections;
public class baifang : MonoBehaviour {
public Texture mouseTexture; //自己想要的鼠标图片
public bool isture = false;
private GameObject clone;
public GameObject game;
public GameObject moxing;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown(0) && isture == true)
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
//Point = hit.point;//得到碰撞点的坐标
print(hit.point);//输出一下
}
print("123");
clone = Instantiate(moxing, Vector3.zero, Quaternion.identity) as GameObject;
clone.transform.localPosition = new Vector3(hit.point.x,0,hit.point.z);
isture = false;
}
}
public void _baifang()
{
isture = true;
}
public void OnGUI()
{
if (isture == true)
{
Cursor.visible = false;
Vector3 mousePos = Input.mousePosition;
GUI.DrawTexture(new Rect(mousePos.x, Screen.height - mousePos.y, mouseTexture.width, mouseTexture.height), mouseTexture);
}
else
{
Cursor.visible = true;
}
}
}