Esempio n. 1
0
    private void Update()
    {
        // only if user double clicks on map
        if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject())
        {
            // first click
            if (!clicked)
            {
                clicked        = true;
                firstClickTime = Time.time;
            }

            // second click
            else
            {
                clicked = false; // reset clicks

                // show materials panel
                materialsPanel.SetActive(true);
                infoPanel.SetActive(false);
                mapPanel.SetActive(false);
                geoCam.SetActive(false);

                // detects if mouse clicks intersects with any tileset
                ray = cam.ScreenPointToRay(Input.mousePosition);
                // Debug.Log(Input.mousePosition);

                Vector2d clickCoords = (cam.ScreenToWorldPoint(Input.mousePosition) - new Vector3(0, cam.transform.position.y, 0))
                                       .GetGeoPosition(map.CenterMercator, map.WorldRelativeScale); // geographic location of point click (in long lat)
                click = Conversions.LatLonToMeters(clickCoords);                                    // in meters
                geoMap.Search(clickCoords);


                // assuming no materials selected
                materialsList.text = "\n<size=25pt>No materials selected. Please select stone and/or timber to retrieve data.</size>";

                // layermask - which materials to display?
                if (timber.isOn || stone.isOn)
                {
                    materialsList.text = ""; // reset text
                    if (timber.isOn)
                    {
                        ShowList(8); // timber layer
                    }
                    if (stone.isOn)
                    {
                        ShowList(9);  // geology layer
                        ShowList(11); // quarry layer
                    }
                }

                pageSetter.SetPages(); // initialize page formatting of materials panel
            }
        }

        // user didn't click, time for double click has passed
        else if (clicked && Time.time - firstClickTime > interval)
        {
            clicked = false;
        }
    }