Beispiel #1
0
    public void AddButton(Dungeon dungeon)
    {
        GameObject goButton = (GameObject)Instantiate(DungeonButton);

        goButton.transform.SetParent(DungeonListContentHolder.transform, false);
        goButton.transform.localScale = new Vector3(1, 1, 1);

        goButton.name = dungeon.Lat + "," + dungeon.Lon;

        Text   tmpButtonText = goButton.GetComponentInChildren <Text>();
        string tmpName       = dungeon.Name;

        if (tmpName.Length > 14)
        {
            tmpName = tmpName.Substring(0, 14).Trim() + "...";
        }

        tmpButtonText.text = tmpName;

        Button tempButton = goButton.GetComponent <Button>();

        tempButton.onClick.AddListener(() => ButtonClicked(dungeon.Lat.ToString(), dungeon.Lon.ToString()));

        void ButtonClicked(string Lat, string Lon)
        {
            //Map.SetCenterLatitudeLongitude(new Mapbox.Utils.Vector2d(double.Parse(Lat), double.Parse(Lon)));
            MapControllerObject.CenterMap(Lat, Lon);
            searchBox.HandleUserInput(Lon + "," + Lat);

            //Map.UpdateMap(new Mapbox.Utils.Vector2d(double.Parse(Lat), double.Parse(Lon)), 16);

            //Map.ResetMap();
            //Map.Initialize(new Mapbox.Utils.Vector2d(double.Parse(Lat), double.Parse(Lon)), 16);
            //Map.UpdateMap(float.Parse(Lat), float.Parse(Lon));
            //Debug.Log("Button clicked = " + btnLatLon);
        }
    }