コード例 #1
0
    public void Clicked()
    {
        if (GameAssistant.Running)
        {
            Vector3 clickPos  = RenderCam.ScreenToWorldPoint(Input.mousePosition);
            Vector3 newRayPos = clickPos + RayTranslation;
            newRayPos.z = MinigameCam.transform.position.z;
            Physics.Raycast(newRayPos, Vector3.forward, out RaycastHit hit, 100.0f);
            Debug.DrawRay(newRayPos, Vector3.forward * 100.0f, Color.green, 2.0f);

            if (hit.collider != null)
            {
                IOurClickable testClickable = hit.collider.GetComponent <IOurClickable>();
                if (testClickable != null)
                {
                    testClickable.Clicked();
                }
            }
            else
            {
                // ~~~ not interacting with focus error
            }
        }
    }
コード例 #2
0
 private bool TryGetClickable(Collider2D coll, out IOurClickable outClickable)
 {
     outClickable = coll.GetComponent <IOurClickable>();
     return(outClickable != null);
 }