Beispiel #1
0
    private void DrawTexturePropsGUI()
    {
        EditorGUILayout.BeginHorizontal();
        EditorGUI.BeginChangeCheck();
        Object oldValue = pTexture.objectReferenceValue;

        EditorGUILayout.PropertyField(pTexture);
        bool changed = EditorGUI.EndChangeCheck();

        OnlineMapsEditorUtils.HelpButton("The texture where the map will be drawn.\nImportant: must have Read / Write Enabled - ON.");
        EditorGUILayout.EndHorizontal();
        if (!changed)
        {
            return;
        }

        Texture2D texture = pTexture.objectReferenceValue as Texture2D;

        if (texture != null && (!Mathf.IsPowerOfTwo(texture.width) || !Mathf.IsPowerOfTwo(texture.height)))
        {
            EditorUtility.DisplayDialog("Error", "Texture width and height must be power of two!!!", "OK");
            pTexture.objectReferenceValue = oldValue;
        }
        else
        {
            CheckAPITextureImporter(texture);
        }

        texture = pTexture.objectReferenceValue as Texture2D;
        if (texture != null)
        {
            map.width  = texture.width;
            map.height = texture.height;
        }
    }
Beispiel #2
0
    private void DrawMapTypes(ref bool dirty)
    {
        if (control != null && !control.useRasterTiles)
        {
            return;
        }
        if (pSource.enumValueIndex == (int)OnlineMapsSource.Resources)
        {
            return;
        }

        DrawProviderGUI();

        if (mapType.provider.types.Length > 1)
        {
            GUIContent[] availableTypes = mapType.provider.types.Select(t => new GUIContent(t.title)).ToArray();
            int          index          = mapType.index;
            EditorGUILayout.BeginHorizontal();
            EditorGUI.BeginChangeCheck();
            index = EditorGUILayout.Popup(new GUIContent("Type", "Type of map texture"), index, availableTypes);
            if (EditorGUI.EndChangeCheck())
            {
                mapType = mapType.provider.types[index];
                pMapType.stringValue = mapType.ToString();
            }
            OnlineMapsEditorUtils.HelpButton("Type (style) of the map");
            EditorGUILayout.EndHorizontal();
        }

        DrawProviderExtraFields(ref dirty, mapType.provider.extraFields);
        DrawProviderExtraFields(ref dirty, mapType.extraFields);
        DrawLabelsGUI();
    }
Beispiel #3
0
    private void DrawProviderGUI()
    {
        EditorGUILayout.BeginHorizontal();
        EditorGUI.BeginChangeCheck();
        providerIndex = EditorGUILayout.Popup("Provider", providerIndex, providersTitle);
        if (EditorGUI.EndChangeCheck())
        {
            mapType = providers[providerIndex].types[0];
            pMapType.stringValue            = mapType.ToString();
            pActiveTypeSettings.stringValue = "";
        }

        OnlineMapsEditorUtils.HelpButton("Tile provider.\nImportant: all tile presets are for testing purpose only. Before using the tile provider, make sure that it suits you by the terms of use and price.");

        EditorGUILayout.EndHorizontal();

        if (mapType.useHTTP)
        {
            EditorGUILayout.HelpBox(mapType.provider.title + " - " + mapType.title + " uses HTTP, which can cause problems in iOS9+.", MessageType.Warning);
        }
        else if (mapType.isCustom)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.BeginVertical();
            GUILayout.Space(5);
            EditorGUILayout.PropertyField(pCustomProviderURL);
            EditorGUILayout.EndVertical();
            if (GUILayout.Button(wizardIconContent, GUILayout.ExpandWidth(false)))
            {
                OnlineMapsCustomURLWizard.OpenWindow();
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            showCustomProviderTokens = Foldout(showCustomProviderTokens, "Available tokens");
            if (showCustomProviderTokens)
            {
                GUILayout.Label("{zoom}");
                GUILayout.Label("{x}");
                GUILayout.Label("{y}");
                GUILayout.Label("{quad}");
                GUILayout.Space(10);
            }
            EditorGUILayout.EndVertical();
        }
    }
Beispiel #4
0
    private void DrawTilesetPropsGUI()
    {
        EditorGUILayout.BeginHorizontal();

        EditorGUILayout.BeginVertical();
        EditorGUILayout.PropertyField(pWidth, cWidth);
        EditorGUILayout.PropertyField(pHeight, cHeight);
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical(GUILayout.Width(16));
        GUILayout.Space(10);
        OnlineMapsEditorUtils.HelpButton("Width / height of the map. It works as a resolution.\nImportant: the map must have a side size of N * 256.");
        EditorGUILayout.EndVertical();

        EditorGUILayout.EndHorizontal();

        int dts = OnlineMapsUtils.tileSize * 2;

        if (pWidth.intValue % 256 != 0)
        {
            EditorGUILayout.HelpBox("Width is not equal to 256 * N, the map will not work correctly.", MessageType.Error);
            if (GUILayout.Button("Fix Width"))
            {
                pWidth.intValue = Mathf.NextPowerOfTwo(pWidth.intValue);
            }
        }
        else if (pHeight.intValue % 256 != 0)
        {
            EditorGUILayout.HelpBox("Height is not equal to 256 * N, the map will not work correctly.", MessageType.Error);
            if (GUILayout.Button("Fix Height"))
            {
                pHeight.intValue = Mathf.NextPowerOfTwo(pHeight.intValue);
            }
        }

        if (pWidth.intValue <= 128)
        {
            pWidth.intValue = dts;
        }
        if (pHeight.intValue <= 128)
        {
            pHeight.intValue = dts;
        }
    }
Beispiel #5
0
    private void DrawLocationGUI(ref bool dirty)
    {
        double px, py;

        map.GetPosition(out px, out py);

        EditorGUILayout.BeginHorizontal();

        EditorGUILayout.BeginVertical();
        EditorGUI.BeginChangeCheck();
        py = EditorGUILayout.DoubleField("Latitude", py);
        px = EditorGUILayout.DoubleField("Longitude", px);

        if (EditorGUI.EndChangeCheck())
        {
            dirty = true;
            map.SetPosition(px, py);
        }

        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical(GUILayout.Width(16));
        GUILayout.Space(10);
        OnlineMapsEditorUtils.HelpButton("Coordinates of the center point of the map");
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();

        EditorGUI.BeginChangeCheck();

        EditorGUILayout.BeginHorizontal();
        float newZoom = EditorGUILayout.Slider("Zoom", map.floatZoom, OnlineMaps.MINZOOM, OnlineMaps.MAXZOOM);

        if (EditorGUI.EndChangeCheck())
        {
            map.floatZoom = newZoom;
            dirty         = true;
        }
        OnlineMapsEditorUtils.HelpButton("Current zoom of the map");
        EditorGUILayout.EndHorizontal();
    }
Beispiel #6
0
    private void DrawMapTypes(ref bool dirty)
    {
        if (control != null && !control.useRasterTiles)
        {
            return;
        }
        if (pSource.enumValueIndex == (int)OnlineMapsSource.Resources)
        {
            return;
        }
        if (pSource.enumValueIndex == (int)OnlineMapsSource.StreamingAssets)
        {
            return;
        }

        DrawProviderGUI();

        if (mapType.provider.types.Length > 1)
        {
            GUIContent[] availableTypes = mapType.provider.types.Select(t => new GUIContent(t.title)).ToArray();
            int          index          = mapType.index;
            EditorGUILayout.BeginHorizontal();
            EditorGUI.BeginChangeCheck();
            index = EditorGUILayout.Popup(new GUIContent("Type", "Type of map texture"), index, availableTypes);
            if (EditorGUI.EndChangeCheck())
            {
                mapType = mapType.provider.types[index];
                pMapType.stringValue = mapType.ToString();
            }
            OnlineMapsEditorUtils.HelpButton("Type (style) of the map");
            EditorGUILayout.EndHorizontal();
        }

        DrawProviderExtraFields(ref dirty, mapType.provider.extraFields);
        DrawProviderExtraFields(ref dirty, mapType.extraFields);
        if (mapType.fullID == "google.satellite")
        {
            if (GUILayout.Button("Detect the latest version of tiles"))
            {
                WebClient client   = new WebClient();
                string    response = client.DownloadString("http://maps.googleapis.com/maps/api/js");
                Match     match    = Regex.Match(response, @"kh\?v=(\d+)");
                if (match.Success)
                {
                    OnlineMapsProvider.ExtraField version = mapType.extraFields.FirstOrDefault(f =>
                    {
                        OnlineMapsProvider.ExtraField ef = f as OnlineMapsProvider.ExtraField;
                        if (ef == null)
                        {
                            return(false);
                        }
                        if (ef.token != "version")
                        {
                            return(false);
                        }
                        return(true);
                    }) as OnlineMapsProvider.ExtraField;
                    if (version != null)
                    {
                        version.value = match.Groups[1].Value;
                    }
                }
            }
        }
        DrawLabelsGUI();
    }