Exemplo n.º 1
0
 private void ShowDismissButton(bool cond)
 {
     if (_ButtonDismiss)
     {
         _ButtonDismiss.SetActive(cond);
         if (!cond)
         {
             UIDismissCan can = _ButtonDismiss.GetComponent <UIDismissCan>();
             if (can)
             {
                 can.setOff();
             }
         }
     }
 }
Exemplo n.º 2
0
    private bool AlternateUITest(Vector3 MouseRaw)
    {
        GraphicRaycaster gr = GameObject.FindGameObjectWithTag("Canvas").GetComponent <GraphicRaycaster>();

        UnityEngine.EventSystems.EventSystem es = GameManager.Instance.transform.GetComponentInChildren <UnityEngine.EventSystems.EventSystem>();

        if (es == null)
        {
            Debug.LogError("NO EventSys");
        }

        //Set up the new Pointer Event
        PointerEventData m_PointerEventData = new PointerEventData(es);

        //Set the Pointer Event Position to that of the mouse position
        m_PointerEventData.position = MouseRaw;

        //Create a list of Raycast Results
        List <RaycastResult> results = new List <RaycastResult>();

        //RayCast it
        if (gr)
        {
            gr.Raycast(m_PointerEventData, results);
        }
        else
        {
            Debug.LogError("NO GraphicRaycaster");
        }

        //For every result returned, output the name of the GameObject on the Canvas hit by the Ray
        foreach (RaycastResult result in results)
        {
            if (_printStatements)
            {
                Debug.LogError("GraphicCaster Hit " + result.gameObject.name);
            }
            if (result.gameObject.GetComponent <Button>())
            {
                if (_printStatements)
                {
                    Debug.Log("Found a Button Setting clicks to false" + result.gameObject);
                }

                if (result.gameObject.GetComponent <UIDismissCan>())
                {
                    _DismissOveride = true;
                    _DismissCan     = result.gameObject.GetComponent <UIDismissCan>();
                    return(false);
                }
                else if (result.gameObject.GetComponent <UIDraggableButton>())
                {
                    if (!result.gameObject.GetComponent <UIDraggableButton>().isSelected())
                    {
                        result.gameObject.GetComponent <UIDraggableButton>().imClicked();
                        return(false);
                    }
                }
                else if (result.gameObject.GetComponent <UIAssignmentVFX>())
                {
                    result.gameObject.GetComponent <UIAssignmentVFX>().imClicked();
                    return(false);
                }
                else if (result.gameObject.GetComponent <UIStaminaButton>())
                {
                    result.gameObject.GetComponent <UIStaminaButton>().imClicked();
                    return(false);
                }
                else if (result.gameObject.GetComponent <UIAssignmentMovement>())
                {
                    result.gameObject.GetComponent <UIAssignmentMovement>().imClicked();

                    return(false);
                }
            }
            else if (result.gameObject.GetComponent <UIStaminaHitBox>())
            {
                result.gameObject.GetComponent <UIStaminaHitBox>().imClicked();
            }
        }
        if (results.Count <= 0 && (_printStatements))
        {
            Debug.LogWarning("We tried to GraphicRaycast UI and failed @" + m_PointerEventData.position);
        }



        m_PointerEventData.position = (MouseRaw);
        results.Clear();
        UnityEngine.EventSystems.EventSystem.current.RaycastAll(m_PointerEventData, results);
        if (results.Count > 0)
        {
            foreach (RaycastResult result in results)
            {
                if (_printStatements)
                {
                    Debug.LogError("Alternate Hit " + result.gameObject.name);
                }
                if (result.gameObject.GetComponent <Button>())
                {
                    if (_printStatements)
                    {
                        Debug.Log("Found a Button Setting clicks to false");
                    }

                    //Might need to check certain buttons scripts to set assignmentDummy=true;


                    return(false);
                }
                else if (result.gameObject.GetComponent <bWorkerScript>())
                {
                    // Debug.Log("Found B Worker Script");
                    result.gameObject.GetComponent <bWorkerScript>().imClicked();
                }
            }
        }
        else if (_printStatements)
        {
            Debug.LogWarning("We tried to ALLRaycast UI and failed @" + m_PointerEventData.position);
        }

        return(true);
    }