在鼠标与场景交点上放一个mark,并于1s后消失:

新建一个空GameObject,命名为moushHitTest,添加下面脚本:

using UnityEngine;
using System.Collections;

public class mouseHit : MonoBehaviour {
    public GameObject m_moushHitMarkPrefab;
    // Use this for initialization
    void Start () {
    
    }
    
    // Update is called once per frame
    void Update () {

if (Input.GetMouseButtonDown (0)) {//left button down
            Ray camRay = Camera.main.ScreenPointToRay (Input.mousePosition);
            RaycastHit hitInfo;
            float camRayLength = 100f;
            bool isHit = Physics.Raycast (camRay,out hitInfo,camRayLength);
            if (isHit) {
                Debug.Log(hitInfo.point);

          Debug.Log(hitInfo.transform.gameObject.name);
                Object instance=Instantiate (m_moushHitMarkPrefab, hitInfo.point, Quaternion.identity);
                instance.name="hitMark";
                //about startCoroutine and yield: http://stackoverflow.com/questions/12932306/how-does-startcoroutine-yield-return-pattern-really-work-in-unity
                StartCoroutine(delayDestroy(instance));

}
        }

}

IEnumerator delayDestroy(Object instance){
        yield return new WaitForSeconds (1.0f);
        Destroy (instance);
    }

}

最新文章

  1. jQuery效率提升建议
  2. hoj 2634 How to earn more
  3. Debian普通用户获取root权限|sudo的安装与配置
  4. C++函数模版
  5. 使用jquery实现简单的拖动效果,分享源码
  6. html标签属性大全
  7. 七 mybatis的延迟加载
  8. html2canvas 踩坑总结
  9. distinct和group by 去掉重复数据分析
  10. 指定路径下建立Access数据库并插入数据
  11. 【js高程学习笔记】关于变量值和函数参数
  12. BZOJ4391 High Card Low Card [Usaco2015 dec](贪心+线段树/set库
  13. oracle常用分析函数 over(partition by xxx order by xxx)
  14. 原生java读取存储为xml格式的数据,并存储到java bean里
  15. asp.net导出excel 问题及服务器的部署dcom组件配置
  16. 【Spring学习笔记-MVC-10】Spring MVC之数据校验
  17. ubuntu 16.04 docker下安装klee环境
  18. zabbix第一篇:zabbix安装及使用
  19. 详解JavaScript的splice()方法
  20. 【BZOJ5100】[POI2018]Plan metra 构造

热门文章

  1. BusyBox 简化嵌入式 Linux 系统
  2. 使用cwrsync做服务器文件夹同步
  3. arcgis python图形信息
  4. ICLR 2013 International Conference on Learning Representations深度学习论文papers
  5. sql数据库出现可疑
  6. CSS:CSS层叠样式表的概述
  7. Python 谷歌翻译
  8. 关于在Visual Studio 2008/2010 和Opencv平台下出现LINK : fatal error
  9. SCU 4313 把一棵树切成每段K个点 (n%k)剩下的点不管
  10. DAS存储未死,再次欲获重生