Example #1
0
    // Update is called once per frame
    void Update()
    {
        MultiTouchEnabled = Input.multiTouchEnabled;
        if (CurES == null)
        {
            return;
        }

        PointOverClickable = CurES.IsPointerOverGameObject();
        var selectGo = CurES.currentSelectedGameObject;

        if (selectGo != null)
        {
            string    objName  = selectGo.name;
            Transform node     = selectGo.transform;
            int       whileCnt = 0;
            while (node.parent != null)
            {
                node    = node.parent;
                objName = node.gameObject.name + "/" + objName;
                whileCnt++;
                if (whileCnt > 10)
                {
                    break;
                }
            }
            SelectObject = objName;
        }
        else
        {
            SelectObject = "";
        }

        UpdateEventSystemRaycast();

        // if (Input.GetMouseButton (0) && FieldCamera.instance != null) {

        //     var castRes = FieldCamera.instance.RaycastAll (Input.mousePosition);
        //     if (castRes.Length > 0) {
        //         FirstRaycast = castRes[0].collider;
        //     } else {
        //         FirstRaycast = null;
        //     }
        // }
    }
Example #2
0
    void UpdateEventSystemRaycast()
    {
        if (Input.GetMouseButton(0))
        {
            tempRaycastResults.Clear();
            FirstRaycast = null;
            RaycastQueue.Clear();

            if (CurES != null)
            {
                PointData.Reset();

                // Raycast event system at the specified point
                PointData.position = Input.mousePosition;

                CurES.RaycastAll(PointData, tempRaycastResults);
                var resultCount = tempRaycastResults.Count;
                // Loop through all results and remove any that don't match the layer mask
//                if (tempRaycastResults.Count > 0)
//                {
//                    for (var i = tempRaycastResults.Count - 1; i >= 0; i--)
//                    {
//                        var raycastResult = tempRaycastResults[i];
//                        var raycastLayer  = 1 << raycastResult.gameObject.layer;
//
//                        if ((raycastLayer & layerMask) == 0)
//                        {
//                            tempRaycastResults.RemoveAt(i);
//                        }
//                    }
//                }

                for (var i = 0; i < resultCount; ++i)
                {
                    var raycastResult = tempRaycastResults[i];
                    RaycastQueue.Add(raycastResult.gameObject);
                }

                if (resultCount > 0)
                {
                    FirstRaycast = tempRaycastResults[0].gameObject;
                }
            }
        }
    }