Exemplo n.º 1
0
            void OnGUI()
            {
                if (guiMap == null)
                {
                    guiMap = new GUIMap();
                }


                debugWindowRect = GUI.Window(12341234, debugWindowRect, (id) =>
                {
                    var mapRect = new Rect(2, 18, 196, 180);
                    using (new GUILayout.AreaScope(mapRect))
                    {
                        guiMap.Center = GeoExtension.Instance.Location;
                        guiMap.Zoom   = 17;
                        guiMap.DrawMap(new Rect(0, 0, 196, 180));
                        // Calculate the player pixel relative to the map
                        var playerMeters        = MapzenGo.Helpers.GM.LatLonToMeters(GeoExtension.Instance.Location);
                        var playerPixel         = MapzenGo.Helpers.GM.MetersToPixels(playerMeters, guiMap.Zoom);
                        var playerPixelRelative = playerPixel + guiMap.PATR;

                        // Do the point handling
                        var pointControl = GUIUtility.GetControlID("PlayerPosition".GetHashCode(), FocusType.Passive);
                        EditorGUI.BeginChangeCheck();
                        var newPlayerPixel = HandleUtil.HandlePointMovement(pointControl, playerPixelRelative.ToVector2(), 10,
                                                                            (point, isOver, isActive) => HandleUtil.DrawPoint(point, 4, Color.cyan,
                                                                                                                              Color.black), MouseCursor.MoveArrow);
                        if (EditorGUI.EndChangeCheck())
                        {
                            // If changed, restore the point to the geochar
                            playerPixel  = newPlayerPixel.ToVector2d() - guiMap.PATR;
                            playerMeters = MapzenGo.Helpers.GM.PixelsToMeters(playerPixel, guiMap.Zoom);
                            GeoExtension.Instance.Location = MapzenGo.Helpers.GM.MetersToLatLon(playerMeters);
                        }

                        guiMap.ProcessEvents(mapRect);
                    }
                    GUI.DragWindow();
                },
                                             "DebugWindow");
            }
 protected override void AfterDrawElements(Rect rect)
 {
     guiMap.ProcessEvents(rect);
 }
Exemplo n.º 3
0
        void OnGUI()
        {
            var paintSimbol = disconnectedSimbol;

            switch (Input.location.status)
            {
            default:
            case LocationServiceStatus.Failed:
            case LocationServiceStatus.Stopped:
                paintSimbol = disconnectedSimbol;
                break;

            case LocationServiceStatus.Initializing:
                paintSimbol = connectingSimbol;
                break;

            case LocationServiceStatus.Running:
                var connecting = ((time > blinkingTime / 2f) ? connectedSimbol : connectingSimbol);
                paintSimbol = IsLocationValid() ? connectedSimbol : connecting;
                break;
            }

            /*if (Event.current.type == EventType.Repaint)
             *  GUI.DrawTexture(new Rect(Screen.width - iconWidth - 5, 5, iconWidth, iconHeight), paintSimbol);*/

            if (guiMap == null)
            {
                guiMap = new GUIMap();
            }

            if (Input.GetKeyDown(KeyCode.G))
            {
                hidden = !hidden;
            }

            if (!hidden && (inMapScene || inZoneControl))
            {
                debugWindowRect = GUI.Window(12341234, debugWindowRect, (id) =>
                {
                    var mapRect = new Rect(2, 18, 196, 180);
                    using (new GUILayout.AreaScope(mapRect))
                    {
                        guiMap.Center = GeoExtension.Instance.Location;
                        guiMap.Zoom   = 17;
                        guiMap.DrawMap(new Rect(0, 0, 196, 180));
                        // Calculate the player pixel relative to the map
                        var playerMeters        = MapzenGo.Helpers.GM.LatLonToMeters(GeoExtension.Instance.Location);
                        var playerPixel         = MapzenGo.Helpers.GM.MetersToPixels(playerMeters, guiMap.Zoom);
                        var playerPixelRelative = playerPixel + guiMap.PATR;

                        // Do the point handling
                        var pointControl   = GUIUtility.GetControlID("PlayerPosition".GetHashCode(), FocusType.Passive);
                        var oldPlayerPixel = playerPixelRelative.ToVector2();
                        var newPlayerPixel = HandlePointMovement(pointControl, oldPlayerPixel, 60,
                                                                 (point, isOver, isActive) =>
                        {
                            var locationRect    = new Rect(0, 0, 30, 30);
                            locationRect.center = point;
                            locationRect.y     -= locationRect.height / 2f;
                            GUI.DrawTexture(locationRect, pointer);
                        });

                        if (oldPlayerPixel != newPlayerPixel)
                        {
                            // If changed, restore the point to the geochar
                            playerPixel  = newPlayerPixel.ToVector2d() - guiMap.PATR;
                            playerMeters = MapzenGo.Helpers.GM.PixelsToMeters(playerPixel, guiMap.Zoom);
                            GeoExtension.Instance.Location = MapzenGo.Helpers.GM.MetersToLatLon(playerMeters);
                        }

                        guiMap.ProcessEvents(mapRect);

                        GUI.Label(new Rect(0, 0, 196, 40), "Drag the pointer to move");
                    }
                    GUI.DragWindow();
                },
                                             "Debug Location");
            }
        }