Пример #1
0
 void Click()
 {
     //The method returns true if our mouse is hovering over UI. We only want to cast our rays if we do not click on ui.
     if (!EventSystem.current.IsPointerOverGameObject())
     {
         RaycastHit hit;
         Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
         if (Physics.Raycast(ray, out hit, rayLength, layermask))
         {
             Debug.Log("You selected the " + hit.transform.name); // ensure you picked right object
             if (hit.transform.GetComponent <Planetholder>() != null)
             {
                 Planetholder planetH = hit.transform.GetComponent <Planetholder>();
                 planetH.OnClick();
             }
             else if (hit.transform.GetComponent <Moonholder>() != null)
             {
                 Moonholder moonH = hit.transform.GetComponent <Moonholder>();
                 moonH.OnClick();
             }
         }
         else
         {
             ui.HidePopup();
         }
     }
 }
Пример #2
0
    public void ShowPopup(Moonholder m)
    {
        PopupPanel.SetActive(true);
        PopupPanel.transform.GetChild(0).GetComponent <Text>().text = m.moon.name;

        ClearImgChildren();
        var t = PopupPanel.transform.GetChild(2);

        foreach (Building b in m.moon.Buildings)
        {
            var txt = Instantiate(textPrefab) as GameObject;
            txt.transform.SetParent(t, false);
            txt.GetComponentInChildren <Text>().text = b.name;
        }
    }