zoukankan      html  css  js  c++  java
  • canvas与sprite射线检测

    public class someclass:monobehaviour

    {

        public EventSystem eventssystem;
        public GraphicRaycaster gra;
        /// <summary>
        /// 射线检测
        /// </summary>
        /// <param name="Name"></param>
        /// <returns></returns>
        public bool MouseOver(string Name)
        {
            var mPointerEventData = new PointerEventData(eventssystem);
            mPointerEventData.position = Input.mousePosition;
            List<RaycastResult> results = new List<RaycastResult>();

            gra.Raycast(mPointerEventData, results);
            return results.Any(data => data.gameObject.name == Name);

        }

    }

        private void Update()
        {
            if (Input.GetMouseButtonDown(0))
            {
                Vector3 point = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                point.z = transform.position.z;
                if (sprite.bounds.Contains(point))
                {
                    ctrl.fsm.PerformTransition(Transition.PieceClick);

                }

            }
        }


  • 相关阅读:
    Lucene教程
    ElasticSearch安装
    MySQL事务
    Java泛型
    Python学习笔记(1)
    @keyframs实现图片gif效果
    glup简单应用---gulpfile.js
    巧用CSS3伪类选择器自定义checkbox和radio的样式
    get传中文参数乱码解决方法
    自定义样式 实现文件控件input[type='file']
  • 原文地址:https://www.cnblogs.com/baozhu/p/12070432.html
Copyright © 2011-2022 走看看