예제 #1
0
    //public void RemoveAll() {
    //	tuioTransmitter.RemoveAll();
    //}


    //
    // surface cursors
    //

    private void CreateSurfaceCursor(Pointer pointer)
    {
        if (surfaceCursors.ContainsKey(pointer.Id))
        {
            RemoveSurfaceCursor(pointer);
        }

        // only create cursor if not over UI (no normal event system tracking mouse and pointer being injected does not exist for IsPointerOverGameObject check)
        if (IsScreenPositionOverUI(pointer.Position))
        {
            return;
        }

        // raycast, only create cursor if no other entities are hit
        Ray          ray = Camera.main.ScreenPointToRay(pointer.Position);
        RaycastHit2D hit = Physics2D.GetRayIntersection(ray);

        if (hit.collider != null && hit.collider != boxCollider2D)
        {
            return;
        }

        SurfaceCursor sc = Instantiate <SurfaceCursor>(surfaceCursorPrefab);

        Vector2 position = Camera.main.ScreenToWorldPoint(pointer.Position);

        sc.transform.localPosition = position;
        sc.transform.SetParent(transform, false);

        surfaceCursors[pointer.Id] = sc;
    }
예제 #2
0
 private void RemoveSurfaceCursors()
 {
     foreach (var keyValue in surfaceCursors)
     {
         SurfaceCursor sc = keyValue.Value;
         Destroy(sc.gameObject);
     }
 }