コード例 #1
0
    private void CheckCameraDistance(OnlineMaps api)
    {
        if (api == null) return;

        Camera tsCamera = (tilesetControl.activeCamera != null) ? tilesetControl.activeCamera : Camera.main;

        if (tsCamera == null) return;

        Vector3 mapCenter = api.transform.position + new Vector3(api.tilesetSize.x / -2, 0, api.tilesetSize.y / 2);
        float distance = (tsCamera.transform.position - mapCenter).magnitude * 1.5f;
        if (distance <= tsCamera.farClipPlane) return;

        EditorGUILayout.BeginVertical(GUI.skin.box);

        EditorGUILayout.HelpBox(
            "Potential problem detected:\n\"Camera - Clipping Planes - Far\" is too small.",
            MessageType.Warning);

        if (GUILayout.Button("Fix Clipping Planes - Far"))
        {
            tsCamera.farClipPlane = distance;
        }

        EditorGUILayout.EndVertical();
    }
コード例 #2
0
    private void OnGUIMarker(int i, ref int index, ref bool hasDeleted, OnlineMaps map)
    {
        OnlineMapsMarker3D marker = control.markers3D[i];
        GUILayout.Label("Marker " + index);
        Vector2 oldPosition = marker.position;
        marker.position.y = EditorGUILayout.FloatField("Latitude: ", marker.position.y);
        marker.position.x = EditorGUILayout.FloatField("Longitude: ", marker.position.x);

        float min = marker.range.min;
        float max = marker.range.max;
        EditorGUILayout.MinMaxSlider(new GUIContent(string.Format("Zooms ({0}-{1}): ", marker.range.min, marker.range.max)), ref min, ref max, 3, 20);
        if (marker.range.Update(Mathf.RoundToInt(min), Mathf.RoundToInt(max))) marker.Update(map.topLeftPosition, map.bottomRightPosition, map.zoom);

        if (Application.isPlaying && marker.position != oldPosition) marker.Update(map.topLeftPosition, map.bottomRightPosition, map.zoom);

        marker.label = EditorGUILayout.TextField("Label: ", marker.label);
        GameObject prefab = marker.prefab;
        marker.prefab = (GameObject)EditorGUILayout.ObjectField("Prefab: ", marker.prefab, typeof(GameObject), false);

        if (Application.isPlaying && marker.prefab != prefab) marker.Reinit(map.topLeftPosition, map.bottomRightPosition, map.zoom);

        if (GUILayout.Button("Remove"))
        {
            control.markers3D[i] = null;
            hasDeleted = true;
        }
        index++;
    }
コード例 #3
0
        private void Start()
        {
            // Get a reference to an instance of the map.
            api = OnlineMaps.instance;

            _borderWeight = borderWeight;
        }
コード例 #4
0
	// Use this for initialization
	void Start ()
	{
		//Brukes ikke før vi eventuelt skal skalere når vi zoomer.
		api = OnlineMaps.instance;
//		api.OnChangeZoom += OnChangeZoom;
//		OnChangeZoom ();
		Debug.Log(api.control.name);
	}
コード例 #5
0
	// Use this for initialization
	void Start () {

		api = GameObject.Find ("Tileset map").GetComponent<OnlineMaps>();
		e = (Enhet)gameObject.GetComponent<OnlineMapsMarker3DInstance>().marker.customData;
		m = (Måling)e.getSenesteMålingGittDato(Manager.currentDate);
		labelText = e.getEnhetsId ();
		showText = true;

	}
コード例 #6
0
ファイル: MapController.cs プロジェクト: juliancruz87/transpp
	private void Awake ()
	{
		foreach (OnlineMaps map in maps)
		{
			if(map.target == currentMap)
			{
				this.map = map;
				this.currentControl = map.target == OnlineMapsTarget.tileset? controlMapTileSet : controlMapGUI;
			}
			else
				map.gameObject.SetActive (false);
		}
	}
コード例 #7
0
ファイル: Helpers.cs プロジェクト: juliancruz87/transpp
	public static List<Vector2> GetPoints (OnlineMaps map)
	{
		List<Vector2> points = new List<Vector2>();
		Vector2 lt = map.topLeftPosition;
		Vector2 rt = new Vector2(map.bottomRightPosition.x,map.topLeftPosition.y);
		Vector2 lb = new Vector2(map.topLeftPosition.x,map.bottomRightPosition.y);
		Vector2 rb = map.bottomRightPosition;
		points.Add (lt);
		points.Add (rt);
		points.Add (lb);
		points.Add (rb);
		return points;
	}
コード例 #8
0
    public static void CheckTarget(OnlineMaps api, OnlineMapsTarget target)
    {
        if (api == null) return;
        if (api.target == target) return;

        EditorGUILayout.BeginVertical(GUI.skin.box);

        string targetName = Enum.GetName(typeof(OnlineMapsTarget), target);
        targetName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(targetName);
        EditorGUILayout.HelpBox("Problem detected:\nWrong target.\nFor this control target must be " + targetName + "!", MessageType.Error);
        if (GUILayout.Button("Fix Target")) api.target = target;

        EditorGUILayout.EndVertical();
    }
コード例 #9
0
    private static void Load(OnlineMaps api)
    {
        if (!Exists()) return;

        string s = EditorPrefs.GetString(prefsKey);
        OnlineMapsXML node = OnlineMapsXML.Load(s);

        foreach (OnlineMapsXML el in node)
        {
            string name = el.name;
            if (name == "Settings") LoadSettings(el, api);
            else if (name == "Control") LoadControl(el, api);
            else if(name == "Markers") LoadMarkers(el, api);
            else if (name == "Markers3D") LoadMarkers3D(el, api);
            else if (name == "LocationService") LoadLocationService(el, api);
        }

        EditorPrefs.DeleteKey(prefsKey);
    }
コード例 #10
0
    private static void LoadControl(OnlineMapsXML el, OnlineMaps api)
    {
        OnlineMapsControlBase control = api.GetComponent<OnlineMapsControlBase>();
        if (control == null) return;

        control.allowAddMarkerByM = el.Get<bool>("AllowAddMarkerByM");
        control.allowZoom = el.Get<bool>("AllowZoom");
        control.allowUserControl = el.Get<bool>("AllowUserControl");
        control.zoomInOnDoubleClick = el.Get<bool>("ZoomInOnDoubleClick");

        if (control is OnlineMapsControlBase3D)
        {
            OnlineMapsControlBase3D control3D = control as OnlineMapsControlBase3D;

            control3D.allowAddMarker3DByN = el.Get<bool>("AllowAddMarker3DByN");
            control3D.allowCameraControl = el.Get<bool>("AllowCameraControl");
            control3D.marker2DMode = (OnlineMapsMarker2DMode)el.Get<int>("Marker2DMode");
            control3D.marker2DSize = el.Get<float>("Marker2DSize");
            control3D.marker3DScale = el.Get<float>("Marker3DScale");
            control3D.activeCamera = GetObject(el.Get<int>("Camera")) as Camera;

            if (control3D.allowCameraControl)
            {
                control3D.cameraDistance = el.Get<float>("CameraDistance");
                control3D.cameraRotation = el.Get<Vector2>("CameraRotation");
                control3D.cameraSpeed = el.Get<Vector2>("CameraSpeed");
            }
        }

        if (control is OnlineMapsTileSetControl)
        {
            OnlineMapsTileSetControl ts = control as OnlineMapsTileSetControl;

            ts.checkMarker2DVisibility = (OnlineMapsTilesetCheckMarker2DVisibility)el.Get<int>("CheckMarker2DVisibility");
            ts.smoothZoom = el.Get<bool>("SmoothZoom");
            ts.useElevation = el.Get<bool>("UseElevation");
            ts.tileMaterial = GetObject(el.Get<int>("TileMaterial")) as Material;
            ts.tilesetShader = GetObject(el.Get<int>("TileShader")) as Shader;
            ts.drawingShader = GetObject(el.Get<int>("DrawingShader")) as Shader;
            ts.markerMaterial = GetObject(el.Get<int>("MarkerMaterial")) as Material;
            ts.markerShader = GetObject(el.Get<int>("MarkerShader")) as Shader;
        }
    }
コード例 #11
0
    private static OnlineMaps GetOnlineMaps(OnlineMapsControlBase control)
    {
        OnlineMaps map = control.GetComponent <OnlineMaps>();

        if (map == null)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);

            EditorGUILayout.HelpBox("Problem detected:\nCan not find OnlineMaps component.", MessageType.Error);

            if (GUILayout.Button("Add OnlineMaps Component"))
            {
                map = control.gameObject.AddComponent <OnlineMaps>();
                UnityEditorInternal.ComponentUtility.MoveComponentUp(map);
            }

            EditorGUILayout.EndVertical();
        }
        return(map);
    }
コード例 #12
0
        /// <summary>
        /// Loading saved state.
        /// </summary>
        private void LoadState()
        {
            if (!PlayerPrefs.HasKey(key))
            {
                return;
            }

            OnlineMaps map = OnlineMaps.instance;

            OnlineMapsXML prefs = OnlineMapsXML.Load(PlayerPrefs.GetString(key));

            OnlineMapsXML generalSettings = prefs["General"];

            map.position = generalSettings.Get <Vector2>("Coordinates");
            map.zoom     = generalSettings.Get <int>("Zoom");

            List <OnlineMapsMarker> markers = new List <OnlineMapsMarker>();

            OnlineMapsMarkerManager.SetItems(markers);
        }
コード例 #13
0
    private void Start()
    {
        map = OnlineMaps.instance;
        map.OnChangePosition += OnChangePosition;

        if (OnlineMapsCameraOrbit.instance != null)
        {
            OnlineMapsCameraOrbit.instance.OnChangedByInput += OnCameraOrbitChangedByInput;
        }

        if (findLocationByIP)
        {
#if UNITY_EDITOR || !UNITY_WEBGL
            OnlineMapsWWW findByIPRequest = new OnlineMapsWWW("https://ipinfo.io/json");
#else
            OnlineMapsWWW findByIPRequest = new OnlineMapsWWW("http://service.infinity-code.com/getlocation.php");
#endif
            findByIPRequest.OnComplete += OnFindLocationComplete;
        }
    }
コード例 #14
0
        private void SaveState()
        {
            OnlineMaps api = OnlineMaps.instance;

            OnlineMapsXML prefs = new OnlineMapsXML("Map");

            // Save position and zoom
            OnlineMapsXML generalSettings = prefs.Create("General");

            generalSettings.Create("Coordinates", api.position);
            generalSettings.Create("Zoom", api.zoom);

            // Save 2D markers
            api.SaveMarkers(prefs);

            // Save 3D markers
            api.GetComponent <OnlineMapsControlBase3D>().SaveMarkers3D(prefs);

            // Save settings to PlayerPrefs
            PlayerPrefs.SetString(key, prefs.outerXml);
        }
コード例 #15
0
    private void OnEnable()
    {
        _instance  = this;
        dragMarker = null;
        map        = GetComponent <OnlineMaps>();
        if (map == null)
        {
            Debug.LogError("Can not find a script OnlineMaps.");
            OnlineMapsUtils.Destroy(this);
            return;
        }
        activeTexture = map.texture;
        OnlineMapsMarkerManager.Init();
        OnlineMapsDrawingElementManager.Init();
        if (resultIsTexture)
        {
            markerDrawer = new OnlineMapsMarkerBufferDrawer(this);
        }

        OnEnableLate();
    }
コード例 #16
0
        private void Start()
        {
            map              = OnlineMaps.instance;
            control          = OnlineMapsTileSetControl.instance;
            elevationManager = OnlineMapsElevationManagerBase.instance;

            double tlx, tly, brx, bry;

            map.GetCorners(out tlx, out tly, out brx, out bry);

            Vector3 position = control.GetWorldPosition(map.position);

            position.y = altitude;
            if (elevationManager != null)
            {
                position.y *= OnlineMapsElevationManagerBase.GetBestElevationYScale(tlx, tly, brx, bry) * elevationManager.scale;
            }

            gameObject.transform.position = position;
            map.GetPosition(out px, out py);
        }
コード例 #17
0
    private Rect GetRect()
    {
        OnlineMaps api         = OnlineMaps.instance;
        Rect       controlRect = api.control.GetRect();
        Rect       uvRect      = api.control.uvRect;

        controlRect.width  /= uvRect.width;
        controlRect.height /= uvRect.height;
        controlRect.x      -= controlRect.width * uvRect.x;
        controlRect.y      -= controlRect.height * uvRect.y;
        Vector2 topLeft = OnlineMapsUtils.LatLongToTilef(api.buffer.topLeftPosition, api.buffer.apiZoom) * OnlineMapsUtils.tileSize;
        Vector2 pos     = GetAlignedPosition(OnlineMapsUtils.LatLongToTilef(position, api.buffer.apiZoom) * OnlineMapsUtils.tileSize);
        float   scaleX  = (controlRect.width / api.width);
        float   scaleY  = (controlRect.height / api.height);

        pos  -= topLeft;
        pos.x = Mathf.RoundToInt(pos.x * scaleX + controlRect.x);
        pos.y = Mathf.RoundToInt(controlRect.yMax - (pos.y + height) * scaleY);

        return(new Rect(pos.x, pos.y, width * scaleX, height * scaleY));
    }
コード例 #18
0
    public override void OnInspectorGUI()
    {
        bool dirty = false;

        OnlineMapsControlBase control = target as OnlineMapsControlBase;

        OnlineMapsControlBaseEditor.CheckMultipleInstances(control, ref dirty);

        OnlineMaps map = OnlineMapsControlBaseEditor.GetOnlineMaps(control);

        OnlineMapsControlBaseEditor.CheckTarget(map, OnlineMapsTarget.texture, ref dirty);

#if !DFGUI
        if (GUILayout.Button("Enable DFGUI"))
        {
            if (EditorUtility.DisplayDialog("Enable DFGUI", "You have DFGUI in your project?", "Yes, I have DFGUI", "Cancel"))
            {
                OnlineMapsEditor.AddCompilerDirective("DFGUI");
            }
        }
#else
        base.OnInspectorGUI();
#endif

        if (dirty)
        {
            EditorUtility.SetDirty(map);
            EditorUtility.SetDirty(control);
            if (!Application.isPlaying)
            {
#if UNITY_5_3P
                EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
#endif
            }
            else
            {
                map.Redraw();
            }
        }
    }
コード例 #19
0
    private void DrawMarkerGUI(int i, ref int index, ref bool hasDeleted, OnlineMaps map)
    {
        EditorGUILayout.BeginVertical(GUI.skin.box);

        OnlineMapsMarker3D marker = control.markers3D[i];
        GUILayout.Label("Marker " + index);
        Vector2 oldPosition = marker.position;

        marker.allowDefaultMarkerEvents = control.allowDefaultMarkerEvents;

        EditorGUI.BeginChangeCheck();
        marker.position.y = EditorGUILayout.FloatField("Latitude: ", marker.position.y);
        marker.position.x = EditorGUILayout.FloatField("Longitude: ", marker.position.x);

        float min = marker.range.min;
        float max = marker.range.max;
        EditorGUILayout.MinMaxSlider(new GUIContent(string.Format("Zooms ({0}-{1}): ", marker.range.min, marker.range.max)), ref min, ref max, 3, 20);
        if (marker.range.Update(Mathf.RoundToInt(min), Mathf.RoundToInt(max)) && EditorApplication.isPlaying)
            marker.Update(map.topLeftPosition, map.bottomRightPosition, map.zoom);

        if (Application.isPlaying && marker.position != oldPosition) marker.Update(map.topLeftPosition, map.bottomRightPosition, map.zoom);

        marker.label = EditorGUILayout.TextField("Label: ", marker.label);
        marker.scale = EditorGUILayout.FloatField("Scale: ", marker.scale);
        GameObject prefab = marker.prefab;
        marker.prefab = (GameObject)EditorGUILayout.ObjectField("Prefab: ", marker.prefab, typeof(GameObject), false);

        if (Application.isPlaying && marker.prefab != prefab) marker.Reinit(map.topLeftPosition, map.bottomRightPosition, map.zoom);

        if (EditorGUI.EndChangeCheck()) EditorUtility.SetDirty(control);

        if (GUILayout.Button("Remove"))
        {
            control.markers3D[i] = null;
            hasDeleted = true;
            if (Application.isPlaying) Destroy(marker.instance);
        }
        index++;
        EditorGUILayout.EndVertical();
    }
コード例 #20
0
        private void Start()
        {
            map = OnlineMaps.instance;

            if (points == null)
            {
                points = new List <Point>();
            }
            if (points.Count == 0)
            {
                points.Add(new Point(OnlineMaps.instance.position));
            }

            Point p1 = points[0];
            Point p2 = points[1];

            double p1x, p1y, p2x, p2y;

            map.projection.CoordinatesToTile(p1.longitude, p1.latitude, map.zoom, out p1x, out p1y);
            map.projection.CoordinatesToTile(p2.longitude, p2.latitude, map.zoom, out p2x, out p2y);

            targetRotation     = (float)OnlineMapsUtils.Angle2D(p1x, p1y, p2x, p2y) - 90;
            transform.rotation = Quaternion.Euler(0, targetRotation, 0);

            distances     = new List <double>();
            totalDistance = 0;

            for (int i = 1; i < points.Count; i++)
            {
                p1 = points[i - 1];
                p2 = points[i];

                double dx, dy;
                OnlineMapsUtils.DistanceBetweenPoints(p1.longitude, p1.latitude, p2.longitude, p2.latitude, out dx, out dy);
                double stepDistance = Math.Sqrt(dx * dx + dy * dy);
                distances.Add(stepDistance);
                totalDistance += stepDistance;
            }
        }
コード例 #21
0
        private void SaveState()
        {
            OnlineMaps map = OnlineMaps.instance;

            //OnlineMapsXML prefs = new OnlineMapsXML("Map");


            // Save position and zoom

            /*OnlineMapsXML generalSettings = prefs.Create("General");
             * generalSettings.Create("Coordinates", map.position);
             * generalSettings.Create("Zoom", map.zoom);
             *
             * // Save 2D markers
             * map.SaveMarkers(prefs);
             *
             * // Save 3D markers
             * OnlineMapsJSONItem markers3DJSON = OnlineMapsMarker3DManager.instance.ToJSON();
             *
             * // Save settings to PlayerPrefs
             * PlayerPrefs.SetString(key, prefs.outerXml);*/
        }
コード例 #22
0
    public override void OnInspectorGUI()
    {
        bool dirty = false;

        serializedObject.Update();

        float oldWidth = EditorGUIUtility.labelWidth;

        EditorGUIUtility.labelWidth = 170;

        OnlineMaps api = OnlineMapsControlBaseEditor.GetOnlineMaps(control);

        OnlineMapsControlBaseEditor.CheckTarget(api, OnlineMapsTarget.texture, ref dirty);

        OnlineMapsControlBaseEditor.CheckMultipleInstances(control, ref dirty);

        DrawPropsGUI(ref dirty);
        DrawMarkersGUI(ref dirty);

        EditorGUIUtility.labelWidth = oldWidth;

        serializedObject.ApplyModifiedProperties();

        if (dirty)
        {
            EditorUtility.SetDirty(api);
            EditorUtility.SetDirty(control);
            if (!Application.isPlaying)
            {
#if UNITY_5_3P
                EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
#endif
            }
            else
            {
                api.Redraw();
            }
        }
    }
コード例 #23
0
        private void Start()
        {
            OnlineMaps api = OnlineMaps.instance;

            // Create markers.
            api.AddMarker(new Vector2(0, 0));
            api.AddMarker(new Vector2(0, 0.01f));
            api.AddMarker(new Vector2(0, -0.01f));

            // Sets a new comparer.
            OnlineMapsTileSetControl.instance.markerComparer = new MarkerComparer();

            // Get the center point and zoom the best for all markers.
            Vector2 center;
            int     zoom;

            OnlineMapsUtils.GetCenterPointAndZoom(api.markers, out center, out zoom);

            // Change the position and zoom of the map.
            api.position = center;
            api.zoom     = zoom;
        }
コード例 #24
0
    public override void OnInspectorGUI()
    {
        bool dirty = false;

        OnlineMapsControlBase control = target as OnlineMapsControlBase;
        OnlineMapsControlBaseEditor.CheckMultipleInstances(control, ref dirty);

        OnlineMaps api = OnlineMapsControlBaseEditor.GetOnlineMaps(control);
        OnlineMapsControlBaseEditor.CheckTarget(api, OnlineMapsTarget.texture, ref dirty);

        #if !NGUI
        if (GUILayout.Button("Enable NGUI")) OnlineMapsEditor.AddCompilerDirective("NGUI");
        #else
        base.OnInspectorGUI();
        #endif

        if (dirty)
        {
            EditorUtility.SetDirty(api);
            Repaint();
        }
    }
コード例 #25
0
    /// <summary>
    /// Converts a list of nodes into an list of points in Unity World Space.
    /// </summary>
    /// <param name="nodes">List of nodes.</param>
    /// <returns>List of points in Unity World Space.</returns>
    protected static List <Vector3> GetLocalPoints(List <OnlineMapsOSMNode> nodes)
    {
        OnlineMaps map = OnlineMaps.instance;
        Vector2    tl  = map.buffer.topLeftPosition;

        double sx, sy;

        map.projection.CoordinatesToTile(tl.x, tl.y, map.buffer.apiZoom, out sx, out sy);

        List <Vector3> localPoints = new List <Vector3>(Mathf.Min(nodes.Count, 8));

        float sw = OnlineMapsUtils.tileSize * map.tilesetSize.x / map.tilesetWidth * map.transform.lossyScale.x;
        float sh = OnlineMapsUtils.tileSize * map.tilesetSize.y / map.tilesetHeight * map.transform.lossyScale.z;

        for (int i = 0; i < nodes.Count; i++)
        {
            double px, py;
            map.projection.CoordinatesToTile(nodes[i].lon, nodes[i].lat, map.buffer.apiZoom, out px, out py);
            localPoints.Add(new Vector3((float)((sx - px) * sw), 0, (float)((py - sy) * sh)));
        }
        return(localPoints);
    }
コード例 #26
0
    private static void Load(OnlineMaps api)
    {
        api.position = LoadPref("Position", api.position);
        api.zoom = LoadPref("Zoom", api.zoom);
        api.provider = (OnlineMapsProviderEnum) LoadPref("Provider", 0);
        api.customProviderURL = LoadPref("CustomProviderURL", "http://localhost/{zoom}/{y}/{x}");
        api.type = LoadPref("Type", 0);
        api.labels = LoadPref("Labels", false);

        api.markers = new OnlineMapsMarker[LoadPref("Marker_Count", 0)];
        for (int i = 0; i < api.markers.Length; i++)
        {
            OnlineMapsMarker marker = new OnlineMapsMarker();
            marker.position = LoadPref("Marker_" + i + "_Position", marker.position);
            marker.range = LoadPref("Marker_" + i + "_Range", marker.range);
            int mid = LoadPref("Marker_" + i + "_Texture", 0);
            if (mid != 0) marker.texture = EditorUtility.InstanceIDToObject(mid) as Texture2D;
            marker.label = LoadPref("Marker_" + i + "_Label", marker.label);
            marker.align = (OnlineMapsAlign) LoadPref("Marker_" + i + "_Align", (int) marker.align);
            api.markers[i] = marker;
        }

        OnlineMapsTextureControl control = api.gameObject.GetComponent<OnlineMapsTextureControl>();
        if (control != null)
        {
            control.markers3D = new OnlineMapsMarker3D[LoadPref("Marker3D_Count", 0)];
            for (int i = 0; i < control.markers3D.Length; i++)
            {
                OnlineMapsMarker3D marker = new OnlineMapsMarker3D();
                marker.position = LoadPref("Marker3D_" + i + "_Position", marker.position);
                marker.range = LoadPref("Marker3D_" + i + "_Range", marker.range);
                Debug.Log(marker.range);
                int mid = LoadPref("Marker3D_" + i + "_Prefab", 0);
                marker.prefab = EditorUtility.InstanceIDToObject(mid) as GameObject;
                marker.label = LoadPref("Marker3D_" + i + "_Label", marker.label);
                control.markers3D[i] = marker;
            }
        }
    }
コード例 #27
0
    /// <summary>
    /// Constructor
    /// </summary>
    /// <param name="map">Reference to the map</param>
    public OnlineMapsGUITooltipDrawer(OnlineMaps map)
    {
        this.map        = map;
        control         = map.control;
        map.OnGUIAfter += DrawTooltips;

        tooltipStyle = new GUIStyle
        {
            normal =
            {
                background = map.tooltipBackgroundTexture,
                textColor  = new Color32(230, 230, 230, 255)
            },
            border       = new RectOffset(8, 8, 8, 8),
            margin       = new RectOffset(4, 4, 4, 4),
            wordWrap     = true,
            richText     = true,
            alignment    = TextAnchor.MiddleCenter,
            stretchWidth = true,
            padding      = new RectOffset(0, 0, 3, 3)
        };
    }
コード例 #28
0
    private void OnGPSEmulatorGUI()
    {
        EditorGUILayout.BeginVertical(GUI.skin.box);

        bool useGPSEmulator = pUseGPSEmulator.boolValue;

        if (useGPSEmulator)
        {
            EditorGUILayout.BeginHorizontal();
            showGPSEmulator = GUILayout.Toggle(showGPSEmulator, "", EditorStyles.foldout, GUILayout.ExpandWidth(false));
        }

        pUseGPSEmulator.boolValue = GUILayout.Toggle(pUseGPSEmulator.boolValue, "Use GPS Emulator", toggleStyle);

        if (useGPSEmulator)
        {
            EditorGUILayout.EndHorizontal();
        }

        if (pUseGPSEmulator.boolValue && showGPSEmulator)
        {
            EditorGUILayout.HelpBox("The emulator is automatically disabled on the devices and use the data from the sensors.", MessageType.Info);

            if (GUILayout.Button("Copy position from Online Maps"))
            {
                OnlineMaps api = (target as OnlineMapsLocationService).GetComponent <OnlineMaps>();
                if (api != null)
                {
                    pEmulatorPosition.vector2Value = api.position;
                }
            }

            EditorGUILayout.PropertyField(pEmulatorPosition, new GUIContent("Position (Lng/Lat)"));
            EditorGUILayout.PropertyField(pEmulatorCompass, new GUIContent("Compass (0-360)"));
        }

        EditorGUILayout.EndVertical();
    }
コード例 #29
0
        private void OnChangeZoom()
        {
            OnlineMaps api = OnlineMaps.instance;

            foreach (OnlineMapsMarker marker in api.markers)
            {
                ShowMarkerLabelsByZoomItem item = marker.customData as ShowMarkerLabelsByZoomItem;
                if (item == null)
                {
                    continue;
                }

                // Update marker labels.
                if (item.zoomRange.InRange(api.zoom))
                {
                    marker.label = item.label;
                }
                else
                {
                    marker.label = "";
                }
            }
        }
コード例 #30
0
    private static void LoadMarkers3D(OnlineMapsXML el, OnlineMaps api)
    {
        OnlineMapsControlBase3D   control = api.GetComponent <OnlineMapsControlBase3D>();
        List <OnlineMapsMarker3D> markers = new List <OnlineMapsMarker3D>();

        foreach (OnlineMapsXML m in el)
        {
            OnlineMapsMarker3D marker = new OnlineMapsMarker3D();

            double mx = m.Get <double>("Longitude");
            double my = m.Get <double>("Latitude");

            marker.SetPosition(mx, my);

            Debug.Log(m["Range"].outerXml);
            marker.range    = m.Get <OnlineMapsRange>("Range");
            marker.label    = m.Get <string>("Label");
            marker.prefab   = GetObject(m.Get <int>("Prefab")) as GameObject;
            marker.rotation = Quaternion.Euler(m.Get <Vector3>("Rotation"));
            markers.Add(marker);
        }
        control.markers3D = markers.ToArray();
    }
コード例 #31
0
    private static void LoadMarkers(OnlineMapsXML el, OnlineMaps api)
    {
        List <OnlineMapsMarker> markers = new List <OnlineMapsMarker>();

        foreach (OnlineMapsXML m in el)
        {
            OnlineMapsMarker marker = new OnlineMapsMarker();

            double mx = m.Get <double>("Longitude");
            double my = m.Get <double>("Latitude");

            marker.SetPosition(mx, my);

            marker.range    = m.Get <OnlineMapsRange>("Range");
            marker.label    = m.Get <string>("Label");
            marker.texture  = GetObject(m.Get <int>("Texture")) as Texture2D;
            marker.align    = (OnlineMapsAlign)m.Get <int>("Align");
            marker.rotation = m.Get <float>("Rotation");
            markers.Add(marker);
        }

        api.markers = markers.ToArray();
    }
コード例 #32
0
        private void Start()
        {
            if (zoomOffset <= 0)
            {
                throw new Exception("Zoom offset should be positive.");
            }
            if (shader == null)
            {
                shader = Shader.Find("Diffuse");
            }

            map     = OnlineMaps.instance;
            control = OnlineMapsTileSetControl.instance;
            OnlineMapsTile.OnTileDownloaded += OnTileDownloaded;
            if (OnlineMapsCache.instance != null)
            {
                OnlineMapsCache.instance.OnLoadedFromCache += OnTileDownloaded;
            }

            map.OnMapUpdated += UpdateMesh;

            InitMesh();
        }
コード例 #33
0
    /// <summary>
    /// Converts a list of nodes into an list of points in Unity World Space.
    /// </summary>
    /// <param name="nodes">List of nodes.</param>
    /// <returns>List of points in Unity World Space.</returns>
    protected static List <Vector3> GetLocalPoints(List <OnlineMapsOSMNode> nodes)
    {
        OnlineMaps map = OnlineMaps.instance;
        Vector2    tl  = map.buffer.topLeftPosition;

        double sx, sy;

        map.projection.CoordinatesToTile(tl.x, tl.y, map.buffer.renderState.zoom, out sx, out sy);

        List <Vector3> localPoints = new List <Vector3>(Mathf.Min(nodes.Count, 8));
        float          zoomCoof    = map.buffer.renderState.zoomCoof;

        float sw = OnlineMapsUtils.tileSize * OnlineMapsTileSetControl.instance.sizeInScene.x / map.width / zoomCoof;
        float sh = OnlineMapsUtils.tileSize * OnlineMapsTileSetControl.instance.sizeInScene.y / map.height / zoomCoof;

        for (int i = 0; i < nodes.Count; i++)
        {
            double px, py;
            map.projection.CoordinatesToTile(nodes[i].lon, nodes[i].lat, map.buffer.renderState.zoom, out px, out py);
            localPoints.Add(new Vector3((float)((sx - px) * sw), 0, (float)((py - sy) * sh)));
        }
        return(localPoints);
    }
コード例 #34
0
    private void OnDisable()
    {
        OnlineMapsThreadManager.Dispose();

        if (_buffer != null)
        {
            _buffer.Dispose();
            _buffer = null;
        }

#if NETFX_CORE
        if (renderThread != null)
        {
            renderThread.Dispose();
        }
#endif
#if !UNITY_WEBGL
        renderThread = null;
#endif

        _control         = null;
        OnChangePosition = null;
        OnChangeZoom     = null;
        OnMapUpdated     = null;
        OnMapUpdated     = null;
        OnUpdateBefore   = null;
        OnUpdateLate     = null;
        OnlineMapsTile.OnGetResourcesPath        = null;
        OnlineMapsTile.OnTileDownloaded          = null;
        OnlineMapsTile.OnTrafficDownloaded       = null;
        OnlineMapsMarkerBase.OnMarkerDrawTooltip = null;

        if (_instance == this)
        {
            _instance = null;
        }
    }
コード例 #35
0
    private static void Load(OnlineMaps api)
    {
        if (!Exists())
        {
            return;
        }

        string        s    = EditorPrefs.GetString(prefsKey);
        OnlineMapsXML node = OnlineMapsXML.Load(s);

        foreach (OnlineMapsXML el in node)
        {
            string name = el.name;
            if (name == "Settings")
            {
                LoadSettings(el, api);
            }
            else if (name == "Control")
            {
                LoadControl(el, api);
            }
            else if (name == "Markers")
            {
                LoadMarkers(el, api);
            }
            else if (name == "Markers3D")
            {
                LoadMarkers3D(el, api);
            }
            else if (name == "LocationService")
            {
                LoadLocationService(el, api);
            }
        }

        EditorPrefs.DeleteKey(prefsKey);
    }
コード例 #36
0
    private void OnEnable()
    {
        CacheSerializedProperties();
        api = (OnlineMaps)target;

        providers      = OnlineMapsProvider.GetProviders();
        providersTitle = providers.Select(p => p.title).ToArray();

        if (string.IsNullOrEmpty(pMapType.stringValue))
        {
            pMapType.stringValue = OnlineMapsProvider.Upgrade(pProvider.enumValueIndex, pType.intValue);
        }

        if (pDefaultMarkerTexture.objectReferenceValue == null)
        {
            pDefaultMarkerTexture.objectReferenceValue = GetIcon("DefaultMarker.png");
        }
        if (pTooltipTexture.objectReferenceValue == null)
        {
            pTooltipTexture.objectReferenceValue = GetIcon("Tooltip.psd");
        }

        string[] files = Directory.GetFiles("Assets", "update_available.png", SearchOption.AllDirectories);
        if (files.Length > 0)
        {
            Texture updateAvailableIcon = AssetDatabase.LoadAssetAtPath(files[0], typeof(Texture)) as Texture;
            updateAvailableContent = new GUIContent("Update Available", updateAvailableIcon, "Update Available");
        }

        OnlineMapsUpdater.CheckNewVersionAvailable();

        mapType       = OnlineMapsProvider.FindMapType(pMapType.stringValue);
        providerIndex = mapType.provider.index;

        serializedObject.ApplyModifiedProperties();
    }
コード例 #37
0
    public OnlineMapsTile(int x, int y, int zoom, OnlineMaps api, bool isMapTile = true)
    {
        int maxX = 2 << (zoom - 1);

        if (x < 0)
        {
            x += maxX;
        }
        else if (x >= maxX)
        {
            x -= maxX;
        }

        this.x    = x;
        this.y    = y;
        this.zoom = zoom;

        OnlineMapsTile.api = api;
        this.isMapTile     = isMapTile;

        provider = api.provider;
        type     = api.type;
        labels   = api.labels;
        language = api.language;

        topLeft        = OnlineMapsUtils.TileToLatLong(x, y, zoom);
        bottomRight    = OnlineMapsUtils.TileToLatLong(x + 1, y + 1, zoom);
        globalPosition = Vector2.Lerp(topLeft, bottomRight, 0.5f);

        trafficURL = String.Format("https://mts0.google.com/vt?pb=!1m4!1m3!1i{0}!2i{1}!3i{2}!2m3!1e0!2sm!3i301114286!2m6!1e2!2straffic!4m2!1soffset_polylines!2s0!5i1!2m12!1e2!2spsm!4m2!1sgid!2sl0t0vMkIqfb3hBb090479A!4m2!1ssp!2s1!5i1!8m2!13m1!14b1!3m25!2sru-RU!3sUS!5e18!12m1!1e50!12m3!1e37!2m1!1ssmartmaps!12m5!1e14!2m1!1ssolid!2m1!1soffset_polylines!12m4!1e52!2m2!1sentity_class!2s0S!12m4!1e26!2m2!1sstyles!2zcy5lOmx8cC52Om9mZixzLnQ6MXxwLnY6b2ZmLHMudDozfHAudjpvZmY!4e0", zoom, x, y);

        if (isMapTile)
        {
            tiles.Add(this);
        }
    }
コード例 #38
0
    private void OnGUI()
    {
        GUIStyle style = new GUIStyle(EditorStyles.textArea);

        style.wordWrap = true;

        scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);

        EditorGUILayout.HelpBox("Tool that helps you to find and replace the value of zoom, x, y in the url of tile.\nSupports: Google Maps, Mapbox.", MessageType.Info);

        EditorGUILayout.LabelField("Original URL");
        EditorGUI.BeginChangeCheck();
        url = EditorGUILayout.TextArea(url, style, GUILayout.Height(100));
        if (EditorGUI.EndChangeCheck())
        {
            ModifyURL();
        }
        EditorGUILayout.Separator();
        EditorGUILayout.LabelField("New URL");
        EditorGUILayout.TextArea(hasError? "Can not identify the type of map": newUrl, style, GUILayout.Height(100));

        EditorGUILayout.EndScrollView();

        EditorGUI.BeginDisabledGroup(hasError);

        if (GUILayout.Button("Apply"))
        {
            OnlineMaps map = FindObjectOfType <OnlineMaps>();
            if (map != null)
            {
                map.customProviderURL = newUrl;
                Close();
            }
        }
        EditorGUI.EndDisabledGroup();
    }
コード例 #39
0
    private void OnEnable()
    {
        map     = GetComponent <OnlineMaps>();
        control = map.control as OnlineMapsControlBaseDynamicMesh;

        bool isFirstEnable = _instance == null;

        _instance = this;

        buildings        = new Dictionary <string, OnlineMapsBuildingBase>();
        unusedBuildings  = new Dictionary <string, OnlineMapsBuildingBase>();
        newBuildingsData = new Queue <OnlineMapsBuildingsNodeData>();

        container = new GameObject("Buildings");
        container.transform.parent        = transform;
        container.transform.localPosition = Vector3.zero;
        container.transform.localRotation = Quaternion.Euler(Vector3.zero);
        container.transform.localScale    = Vector3.one;

        if (!isFirstEnable)
        {
            Start();
        }
    }
    public override void OnInspectorGUI()
    {
#if !UNITY_2017_2_OR_NEWER || ONLINEMAPS_GUITEXTURE
        bool dirty = false;

        OnlineMapsControlBase control = target as OnlineMapsControlBase;
        OnlineMapsControlBaseEditor.CheckMultipleInstances(control, ref dirty);

        OnlineMaps map = OnlineMapsControlBaseEditor.GetOnlineMaps(control);
        OnlineMapsControlBaseEditor.CheckTarget(map, OnlineMapsTarget.texture, ref dirty);

        base.OnInspectorGUI();

        if (dirty)
        {
            EditorUtility.SetDirty(map);
            EditorUtility.SetDirty(control);
            if (!Application.isPlaying)
            {
#if UNITY_5_3P
                EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
#endif
            }
            else
            {
                map.Redraw();
            }
        }
#else
        EditorGUILayout.HelpBox("GUITexture is part of the legacy GUI, and will be removed in future versions of Unity Editor.", MessageType.Warning);
        if (GUILayout.Button("Enable GUITexture"))
        {
            OnlineMapsEditor.AddCompilerDirective("ONLINEMAPS_GUITEXTURE");
        }
#endif
    }
コード例 #41
0
ファイル: OnlineMapsTile.cs プロジェクト: dimatti/maps_test
    /// <summary>
    /// Constructor
    /// </summary>
    /// <param name="x">Tile X</param>
    /// <param name="y">Tile Y</param>
    /// <param name="zoom">Tile zoom</param>
    /// <param name="map">Reference to the map</param>
    /// <param name="isMapTile">Should this tile be displayed on the map?</param>
    public OnlineMapsTile(int x, int y, int zoom, OnlineMaps map, bool isMapTile = true)
    {
        remainDownloadsAttempts = countDownloadsAttempts;
        int maxX = 1 << zoom;

        if (x < 0)
        {
            x += maxX;
        }
        else if (x >= maxX)
        {
            x -= maxX;
        }

        this.x    = x;
        this.y    = y;
        this.zoom = zoom;

        _map           = map;
        this.isMapTile = isMapTile;

        double tlx, tly, brx, bry;

        map.projection.TileToCoordinates(x, y, zoom, out tlx, out tly);
        map.projection.TileToCoordinates(x + 1, y + 1, zoom, out brx, out bry);
        topLeft     = new OnlineMapsVector2d(tlx, tly);
        bottomRight = new OnlineMapsVector2d(brx, bry);

        globalPosition = Vector2.Lerp(topLeft, bottomRight, 0.5f);
        key            = OnlineMapsTileManager.GetTileKey(zoom, x, y);

        if (isMapTile)
        {
            map.tileManager.Add(this);
        }
    }
コード例 #42
0
    /// <summary>
    /// Converts a list of nodes into an list of points in Unity World Space.
    /// </summary>
    /// <param name="nodes">List of nodes.</param>
    /// <returns>List of points in Unity World Space.</returns>
    protected static List <Vector3> GetLocalPoints(List <OnlineMapsOSMNode> nodes)
    {
        OnlineMaps api = OnlineMaps.instance;
        double     tlx, tly;

        api.GetTopLeftPosition(out tlx, out tly);

        double sx, sy;

        api.projection.CoordinatesToTile(tlx, tly, api.buffer.apiZoom, out sx, out sy);

        List <Vector3> localPoints = new List <Vector3>(nodes.Count);

        float sw = OnlineMapsUtils.tileSize * api.tilesetSize.x / api.tilesetWidth;
        float sh = OnlineMapsUtils.tileSize * api.tilesetSize.y / api.tilesetHeight;

        for (int i = 0; i < nodes.Count; i++)
        {
            double px, py;
            api.projection.CoordinatesToTile(nodes[i].lon, nodes[i].lat, api.buffer.apiZoom, out px, out py);
            localPoints.Add(new Vector3((float)((sx - px) * sw), 0, (float)((py - sy) * sh)));
        }
        return(localPoints);
    }
コード例 #43
0
    public static void Save(OnlineMaps api)
    {
        SetPref("Position", api.position);
        SetPref("Zoom", api.zoom);
        SetPref("Provider", (int) api.provider);
        SetPref("CustomProviderURL", api.customProviderURL);
        SetPref("Type", api.type);
        SetPref("Labels", api.labels);

        SetPref("Marker_Count", api.markers.Length);
        for (int i = 0; i < api.markers.Length; i++)
        {
            OnlineMapsMarker marker = api.markers[i];
            SetPref("Marker_" + i + "_Position", marker.position);
            SetPref("Marker_" + i + "_Range", marker.range);
            SetPref("Marker_" + i + "_Texture", marker.texture != null ? marker.texture.GetInstanceID() : 0);
            SetPref("Marker_" + i + "_Label", marker.label);
            SetPref("Marker_" + i + "_Align", (int) marker.align);
        }

        OnlineMapsTextureControl control = api.gameObject.GetComponent<OnlineMapsTextureControl>();
        if (control != null)
        {
            SetPref("Marker3D_Count", control.markers3D.Length);
            for (int i = 0; i < control.markers3D.Length; i++)
            {
                OnlineMapsMarker3D marker = control.markers3D[i];
                SetPref("Marker3D_" + i + "_Position", marker.position);
                SetPref("Marker3D_" + i + "_Range", marker.range);
                SetPref("Marker3D_" + i + "_Prefab", marker.prefab.GetInstanceID());
                SetPref("Marker3D_" + i + "_Label", marker.label);
            }
        }
    }
コード例 #44
0
    private void Start()
    {
        rwt = GetComponent<RealWorldTerrainContainer>();
        if (rwt == null)
        {
            Debug.LogError("Real World Terrain Connector should be together c Real World Terrain Container.");
            DestroyImmediate(this);
            return;
        }

        if (positionMode == OnlineMapsRWTConnectorPositionMode.transform && targetTransform == null)
        {
            Debug.LogError("Target Transform is not specified.");
            DestroyImmediate(this);
            return;
        }

        api = OnlineMaps.instance;

        if (mode == OnlineMapsRWTConnectorMode.centerOnPosition)
        {
            api.position = currentPosition;
        }
        else if (mode == OnlineMapsRWTConnectorMode.markerOnPosition)
        {
            marker = api.AddMarker(currentPosition, markerTexture, markerLabel);
        }
    }
コード例 #45
0
 private void OnEnable()
 {
     _instance = this;
     dragMarker = null;
     api = GetComponent<OnlineMaps>();
     activeTexture = api.texture;
     if (api == null)
     {
         Debug.LogError("Can not find a script OnlineMaps.");
         Destroy(this);
         return;
     }
     api.control = this;
     OnEnableLate();
 }
コード例 #46
0
 private void Start()
 {
     api = OnlineMaps.instance;
     api.OnChangePosition += OnChangePosition;
 }
コード例 #47
0
 private void OnEnable()
 {
     api = (OnlineMaps) target;
     if (api.defaultMarkerTexture == null) api.defaultMarkerTexture = GetIcon("DefaultMarker.png");
     if (api.skin == null)
     {
         api.skin =
             (GUISkin)
                 AssetDatabase.LoadAssetAtPath("Assets/Infinity Code/Online maps/Skin/DefaultSkin.guiskin",
                     typeof (GUISkin));
     }
 }
コード例 #48
0
// ReSharper disable once UnusedMember.Local
    private void OnDisable ()
    {
        if (_instance == this) _instance = null;

#if !UNITY_WEBGL
        if (renderThread != null)
        {
#if UNITY_IOS
            renderThread.Interrupt();
#else
            renderThread.Abort();
#endif
        }
        renderThread = null;
#endif
    }
コード例 #49
0
 private void Start()
 {
     api = OnlineMaps.instance;
     api.OnStartDownloadTile += OnStartDownloadTile;
 }
コード例 #50
0
    private Texture2D CreateTexture(OnlineMaps map)
    {
        string texturePath = string.Format("Assets/{0}.png", textureFilename);
        map.texture = new Texture2D(textureWidth, textureHeight);
        File.WriteAllBytes(texturePath, map.texture.EncodeToPNG());
        AssetDatabase.Refresh();
        TextureImporter textureImporter = AssetImporter.GetAtPath(texturePath) as TextureImporter;
        if (textureImporter != null)
        {
            textureImporter.mipmapEnabled = false;
            textureImporter.isReadable = true;
            textureImporter.textureFormat = TextureImporterFormat.RGB24;
            textureImporter.maxTextureSize = Mathf.Max(textureWidth, textureHeight);

            if (mapType == 0 && (mapControl2D == 1 || mapControl2D == 2))
            {
                textureImporter.spriteImportMode = SpriteImportMode.Single;
                textureImporter.npotScale = TextureImporterNPOTScale.None;
            }

            AssetDatabase.ImportAsset(texturePath, ImportAssetOptions.ForceUpdate);
            map.texture = (Texture2D)AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D));
        }
        return map.texture;
    }
コード例 #51
0
    private static void LoadMarkers(OnlineMapsXML el, OnlineMaps api)
    {
        List<OnlineMapsMarker> markers = new List<OnlineMapsMarker>();

        foreach (OnlineMapsXML m in el)
        {
            OnlineMapsMarker marker = new OnlineMapsMarker();
            marker.position = m.Get<Vector2>("Position");
            marker.range = m.Get<OnlineMapsRange>("Range");
            marker.label = m.Get<string>("Label");
            marker.texture = GetObject(m.Get<int>("Texture")) as Texture2D;
            marker.align = (OnlineMapsAlign)m.Get<int>("Align");
            marker.rotation = m.Get<float>("Rotation");
            markers.Add(marker);
        }

        api.markers = markers.ToArray();
    }
コード例 #52
0
 public OnlineMapsBuffer(OnlineMaps api)
 {
     this.api = api;
     newTiles = new List<OnlineMapsTile>();
 }
コード例 #53
0
ファイル: ExampleGUI.cs プロジェクト: juliancruz87/transpp
// ReSharper disable once UnusedMember.Local
    private void OnEnable()
    {
        api = GetComponent<OnlineMaps>();
    }
コード例 #54
0
    private static void LoadMarkers3D(OnlineMapsXML el, OnlineMaps api)
    {
        OnlineMapsControlBase3D control = api.GetComponent<OnlineMapsControlBase3D>();
        List<OnlineMapsMarker3D> markers = new List<OnlineMapsMarker3D>();

        foreach (OnlineMapsXML m in el)
        {
            OnlineMapsMarker3D marker = new OnlineMapsMarker3D();
            marker.position = m.Get<Vector2>("Position");
            marker.range = m.Get<OnlineMapsRange>("Range");
            marker.label = m.Get<string>("Label");
            marker.prefab = GetObject(m.Get<int>("Prefab")) as GameObject;
            marker.rotation = Quaternion.Euler(m.Get<Vector3>("Rotation"));
            markers.Add(marker);
        }
        control.markers3D = markers.ToArray();
    }
コード例 #55
0
 public OnlineMapsTile(int x, int y, int zoom, OnlineMaps api, OnlineMapsTile parent)
     : this(x, y, zoom, api)
 {
     this.parent = parent;
     if (parent != null && parent.status == OnlineMapsTileStatus.loaded) parent.SetChildColor(this);
 }
コード例 #56
0
    private static void LoadLocationService(OnlineMapsXML el, OnlineMaps api)
    {
        OnlineMapsLocationService ls = api.GetComponent<OnlineMapsLocationService>();
        ls.desiredAccuracy = el.Get<float>("DesiredAccuracy");
        ls.updatePosition = el.Get<bool>("UpdatePosition");
        ls.createMarkerInUserPosition = el.Get<bool>("CreateMarkerInUserPosition");
        ls.restoreAfter = el.Get<int>("RestoreAfter");

        if (ls.createMarkerInUserPosition)
        {
            ls.markerType = (OnlineMapsLocationServiceMarkerType) el.Get<int>("MarkerType");

            if (ls.markerType == OnlineMapsLocationServiceMarkerType.twoD)
            {
                ls.marker2DTexture = GetObject(el.Get<int>("Marker2DTexture")) as Texture2D;
                ls.marker2DAlign = (OnlineMapsAlign) el.Get<int>("Marker2DAlign");
            }
            else ls.marker3DPrefab = GetObject(el.Get<int>("Marker3DPrefab")) as GameObject;

            ls.markerTooltip = el.Get<string>("MarkerTooltip");
            ls.useCompassForMarker = el.Get<bool>("UseCompassForMarker");
        }

        ls.useGPSEmulator = el.Get<bool>("UseGPSEmulator");
        if (ls.useGPSEmulator)
        {
            ls.emulatorPosition = el.Get<Vector2>("EmulatorPosition");
            ls.emulatorCompass = el.Get<float>("EmulatorCompass");
        }
    }
コード例 #57
0
    private void OnEnable()
    {
        _instance = this;

        if (language == "") language = provider != OnlineMapsProviderEnum.nokia ? "en" : "eng";
        if (drawingElements == null) drawingElements = new List<OnlineMapsDrawingElement>();
        _provider = provider;
        _type = type;
        _language = language;

        UpdateTopLeftPosition();
        UpdateBottonRightPosition();
    }
コード例 #58
0
    private static void LoadSettings(OnlineMapsXML el, OnlineMaps api)
    {
        api.position = el.Get<Vector2>("Position");
        api.zoom = el.Get<int>("Zoom");

        if (api.target == OnlineMapsTarget.texture)
        {
            api.texture = GetObject(el.Get<int>("Texture")) as Texture2D;
        }
        else
        {
            api.tilesetWidth = el.Get<int>("TilesetWidth");
            api.tilesetHeight = el.Get<int>("TilesetHeight");
            api.tilesetSize = el.Get<Vector2>("TilesetSize");
        }

        api.source = (OnlineMapsSource) el.Get<int>("Source");
        api.provider = (OnlineMapsProviderEnum) el.Get<int>("Provider");
        if (api.provider == OnlineMapsProviderEnum.custom) api.customProviderURL = el.Get<string>("CustomProviderURL");
        api.type = el.Get<int>("Prefs");
        api.labels = el.Get<bool>("Labels");
        api.traffic = el.Get<bool>("Traffic");
        api.redrawOnPlay = el.Get<bool>("RedrawOnPlay");
        api.useSmartTexture = el.Get<bool>("UseSmartTexture");
        api.emptyColor = el.Get<Color>("EmptyColor");
        api.defaultTileTexture = GetObject(el.Get<int>("DefaultTileTexture")) as Texture2D;
        api.skin = GetObject(el.Get<int>("Skin")) as GUISkin;
        api.defaultMarkerTexture = GetObject(el.Get<int>("DefaultMarkerTexture")) as Texture2D;
        api.defaultMarkerAlign = (OnlineMapsAlign) el.Get<int>("DefaultMarkerAlign");
        api.showMarkerTooltip = (OnlineMapsShowMarkerTooltip) el.Get<int>("ShowMarkerTooltip");
        api.useSoftwareJPEGDecoder = el.Get<bool>("UseSoftwareJPEGDecoder");
    }
コード例 #59
0
    private void OnEnable()
    {
        api = (OnlineMaps) target;

        double lng, lat;
        api.GetPosition(out lng, out lat);

        if (api._position != Vector2.zero && lng == 0 && lat == 0)
        {
            api.position = api._position;
            api._position = Vector2.zero;
        }

        if (api.defaultMarkerTexture == null) api.defaultMarkerTexture = GetIcon("DefaultMarker.png");
        if (api.skin == null)
        {
            api.skin =
                (GUISkin)
                    AssetDatabase.LoadAssetAtPath("Assets/Infinity Code/Online maps/Skin/DefaultSkin.guiskin",
                        typeof (GUISkin));
        }

        string[] files = Directory.GetFiles("Assets", "update_available.png", SearchOption.AllDirectories);
        if (files.Length > 0)
        {
            Texture updateAvailableIcon = AssetDatabase.LoadAssetAtPath(files[0], typeof (Texture)) as Texture;
            updateAvailableContent = new GUIContent("Update Available", updateAvailableIcon, "Update available");
        }

        OnlineMapsUpdater.CheckNewVersionAvailable();
    }
コード例 #60
0
// ReSharper disable once UnusedMember.Global
    public void Awake()
    {
        _instance = this;

        if (target == OnlineMapsTarget.texture)
        {
            width = texture.width;
            height = texture.height;
        }
        else
        {
            width = tilesetWidth;
            height = tilesetHeight;
            texture = null;
        }

        control = GetComponent<OnlineMapsControlBase>();
        if (control == null) Debug.LogError("Can not find a Control.");
        else control.OnAwakeBefore();

        if (target == OnlineMapsTarget.texture)
        {
            if (texture != null) defaultColors = texture.GetPixels();

            if (defaultTileTexture == null)
            {
                OnlineMapsTile.defaultColors = new Color[OnlineMapsUtils.sqrTileSize];
                for (int i = 0; i < OnlineMapsUtils.sqrTileSize; i++) OnlineMapsTile.defaultColors[i] = emptyColor;
            }
            else OnlineMapsTile.defaultColors = defaultTileTexture.GetPixels();
        }

        foreach (OnlineMapsMarker marker in markers) marker.Init();

        if (target == OnlineMapsTarget.texture && useSmartTexture && smartTexture == null)
        {
            smartTexture = new Texture2D(texture.width / 2, texture.height / 2, TextureFormat.RGB24, false);
        }
    }