示例#1
0
    private void DrawProvider(ref bool allowCreate)
    {
        EditorGUI.BeginChangeCheck();
        providerIndex = EditorGUILayout.Popup("Provider", providerIndex, providersTitle);
        if (EditorGUI.EndChangeCheck())
        {
            activeMapType = providers[providerIndex].types[0];
        }

        if (activeMapType.isCustom)
        {
            customProviderURL = EditorGUILayout.TextField("URL: ", customProviderURL);

            EditorGUILayout.BeginVertical(GUI.skin.box);
            showCustomProviderTokens = OnlineMapsEditor.Foldout(showCustomProviderTokens, "Available tokens");
            if (showCustomProviderTokens)
            {
                GUILayout.Label("{zoom}");
                GUILayout.Label("{x}");
                GUILayout.Label("{y}");
                GUILayout.Label("{quad}");
                GUILayout.Space(10);
            }
            EditorGUILayout.EndVertical();
        }
    }
    private void OnMaterialsGUI(ref bool dirty)
    {
        bool showMaterialGroup = showMaterials;

        if (showMaterialGroup)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
        }

        if (buildings.materials == null)
        {
            buildings.materials = new OnlineMapsBuildingMaterial[0];
        }

        showMaterials = OnlineMapsEditor.Foldout(showMaterials, "Materials");
        if (showMaterials)
        {
            int deleteIndex = -1;
            for (int i = 0; i < buildings.materials.Length; i++)
            {
                OnlineMapsBuildingMaterial material = buildings.materials[i];
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("X", GUILayout.ExpandWidth(false)))
                {
                    deleteIndex = i;
                }
                GUILayout.Label((i + 1) + ": ");
                EditorGUILayout.EndHorizontal();

                EditorGUI.BeginChangeCheck();
                material.wall =
                    EditorGUILayout.ObjectField("Wall material", material.wall, typeof(Material), false) as Material;
                material.roof =
                    EditorGUILayout.ObjectField("Roof material", material.roof, typeof(Material), false) as Material;
                material.scale = EditorGUILayout.Vector2Field("Scale", material.scale);

                if (EditorGUI.EndChangeCheck())
                {
                    dirty = true;
                }
            }

            if (deleteIndex != -1)
            {
                ArrayUtility.RemoveAt(ref buildings.materials, deleteIndex);
                dirty = true;
            }

            if (GUILayout.Button("Add Material"))
            {
                ArrayUtility.Add(ref buildings.materials, new OnlineMapsBuildingMaterial());
                dirty = true;
            }
        }

        if (showMaterialGroup)
        {
            EditorGUILayout.EndVertical();
        }
    }
示例#3
0
    private void DrawProvider(ref bool allowCreate)
    {
        EditorGUI.BeginChangeCheck();
        provider =
            (OnlineMapsProviderEnum)
            EditorGUILayout.EnumPopup(new GUIContent("Provider: ", "Provider of tiles"), provider);
        if (EditorGUI.EndChangeCheck())
        {
            mapProviderType = 0;
        }

        if (provider == OnlineMapsProviderEnum.custom)
        {
            customProviderURL = EditorGUILayout.TextField("URL: ", customProviderURL);

            EditorGUILayout.BeginVertical(GUI.skin.box);
            showCustomProviderTokens = OnlineMapsEditor.Foldout(showCustomProviderTokens, "Available tokens");
            if (showCustomProviderTokens)
            {
                GUILayout.Label("{zoom}");
                GUILayout.Label("{x}");
                GUILayout.Label("{y}");
                GUILayout.Label("{quad}");
                GUILayout.Space(10);
            }
            EditorGUILayout.EndVertical();
        }
    }
示例#4
0
 private void DrawAvailableTokens()
 {
     EditorGUILayout.BeginVertical(GUI.skin.box);
     showPathTokens = OnlineMapsEditor.Foldout(showPathTokens, "Available Tokens");
     if (showPathTokens)
     {
         GUILayout.Label("{pid} - Provider ID");
         GUILayout.Label("{mid} - MapType ID");
         GUILayout.Label("{zoom}, {z} - Tile Zoom");
         GUILayout.Label("{x} - Tile X");
         GUILayout.Label("{y} - Tile Y");
         GUILayout.Label("{quad} - Tile Quad Key");
         GUILayout.Label("{lng} - Language code");
         GUILayout.Label("{lbs} - Labels");
         GUILayout.Space(10);
     }
     EditorGUILayout.EndVertical();
 }
    private void OnMaterialsGUI(ref bool dirty)
    {
        bool showMaterialGroup = showMaterials;

        if (showMaterialGroup)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
        }

        showMaterials = OnlineMapsEditor.Foldout(showMaterials, "Materials");
        if (showMaterials)
        {
            int removedIndex = -1;
            for (int i = 0; i < pMaterials.arraySize; i++)
            {
                EditorGUILayout.BeginVertical(GUI.skin.box);
                OnlineMapsBuildingMaterialPropertyDrawer.isRemoved = false;
                EditorGUILayout.PropertyField(pMaterials.GetArrayElementAtIndex(i), new GUIContent("Material " + (i + 1)));
                if (OnlineMapsBuildingMaterialPropertyDrawer.isRemoved)
                {
                    removedIndex = i;
                }
                EditorGUILayout.EndHorizontal();
            }

            if (removedIndex != -1)
            {
                ArrayUtility.RemoveAt(ref buildings.materials, removedIndex);
                dirty = true;
            }

            if (GUILayout.Button("Add Material"))
            {
                ArrayUtility.Add(ref buildings.materials, new OnlineMapsBuildingMaterial());
                dirty = true;
            }
        }

        if (showMaterialGroup)
        {
            EditorGUILayout.EndVertical();
        }
    }
示例#6
0
    private void OnFileCacheGUI()
    {
        bool fileCache = pUseFileCache.boolValue;

        if (fileCache)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
        }
        EditorGUILayout.PropertyField(pUseFileCache, new GUIContent("File Cache"));

        if (pUseFileCache.boolValue)
        {
#if UNITY_WEBPLAYER || UNITY_WEBGL
            EditorGUILayout.HelpBox("File Cache is not supported for Webplayer and WebGL.", MessageType.Warning);
#endif
            CheckFileCacheSize();


            EditorGUILayout.PropertyField(pMaxFileCacheSize, new GUIContent("Size (mb)"));
            pFileCacheUnloadRate.floatValue = EditorGUILayout.Slider("Unload (%)", Mathf.RoundToInt(pFileCacheUnloadRate.floatValue * 100), 1, 50) / 100;
            EditorGUILayout.PropertyField(pFileCacheLocation, new GUIContent("Cache Location"));
            if (pFileCacheLocation.enumValueIndex == (int)OnlineMapsCache.CacheLocation.custom)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PropertyField(pFileCacheCustomPath, new GUIContent("Cache Folder"));
                if (GUILayout.Button("...", GUILayout.ExpandWidth(false)))
                {
                    string folder = EditorUtility.OpenFolderPanel("Cache folder", pFileCacheCustomPath.stringValue, "");
                    if (!string.IsNullOrEmpty(folder))
                    {
                        pFileCacheCustomPath.stringValue = folder;
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(pFileCacheTilePath, new GUIContent("Tile Path"));
            if (GUILayout.Button("Open", GUILayout.ExpandWidth(false)))
            {
                Process.Start(cache.GetFileCacheFolder().ToString());
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginVertical(GUI.skin.box);
            showPathTokens = OnlineMapsEditor.Foldout(showPathTokens, "Available Tokens");
            if (showPathTokens)
            {
                GUILayout.Label("{pid} - Provider ID");
                GUILayout.Label("{mid} - MapType ID");
                GUILayout.Label("{zoom}, {z} - Tile Zoom");
                GUILayout.Label("{x} - Tile X");
                GUILayout.Label("{y} - Tile Y");
                GUILayout.Label("{quad} - Tile Quad Key");
                GUILayout.Label("{lng} - Language code");
                GUILayout.Label("{lbs} - Labels");
                GUILayout.Space(10);
            }
            EditorGUILayout.EndVertical();

            if (Application.isPlaying || !fileCacheSize.HasValue)
            {
                fileCacheSize = cache.GetFileCacheSizeFast();
            }

            float  fileCacheSizeMb  = fileCacheSize.Value / 1000000f;
            string fileCacheSizeStr = fileCacheSizeMb.ToString("F2");
            EditorGUILayout.LabelField("Current Size (mb)", fileCacheSizeStr);
            if (GUILayout.Button("Clear"))
            {
                cache.ClearFileCache();
                fileCacheSize = null;
            }
        }

        if (fileCache)
        {
            EditorGUILayout.EndVertical();
        }
    }
    protected void DrawMarkersGUI(ref bool dirty)
    {
        if (control.markers3D == null)
        {
            control.markers3D = new OnlineMapsMarker3D[0];
            dirty             = true;
        }

        EditorGUILayout.BeginVertical(GUI.skin.box);
        showMarkers = OnlineMapsEditor.Foldout(showMarkers, "3D markers");

        if (showMarkers)
        {
            EditorGUI.BeginChangeCheck();
            control.marker3DScale            = EditorGUILayout.FloatField("Marker3D Scale: ", control.marker3DScale);
            control.allowDefaultMarkerEvents = EditorGUILayout.Toggle("Allow Default Marker Events: ", control.allowDefaultMarkerEvents);
            if (EditorGUI.EndChangeCheck())
            {
                dirty = true;
            }

            int  index      = 1;
            bool hasDeleted = false;

            OnlineMaps map = control.GetComponent <OnlineMaps>();

            for (int i = 0; i < control.markers3D.Length; i++)
            {
                DrawMarkerGUI(i, ref index, ref hasDeleted, map, ref dirty);
            }

            if (hasDeleted)
            {
                List <OnlineMapsMarker3D> markers = control.markers3D.ToList();
                markers.RemoveAll(m => m == null);
                control.markers3D = markers.ToArray();
                if (Application.isPlaying)
                {
                    OnlineMaps.instance.Redraw();
                }
                dirty = true;
            }

            EditorGUILayout.Space();

            if (GUILayout.Button("Add marker"))
            {
                if (!Application.isPlaying)
                {
                    OnlineMapsMarker3D marker = new OnlineMapsMarker3D
                    {
                        position = control.GetComponent <OnlineMaps>().position,
                        scale    = control.marker3DScale
                    };
                    List <OnlineMapsMarker3D> markers = new List <OnlineMapsMarker3D>(control.markers3D)
                    {
                        marker
                    };
                    control.markers3D = markers.ToArray();
                }
                else
                {
                    GameObject prefab = GameObject.CreatePrimitive(PrimitiveType.Cube);
                    control.AddMarker3D(OnlineMaps.instance.position, prefab);
                    DestroyImmediate(prefab);
                }
                EditorUtility.SetDirty(control);
            }
        }

        EditorGUILayout.EndVertical();
    }
    protected void DrawMarkersGUI(ref bool dirty)
    {
        EditorGUILayout.BeginVertical(GUI.skin.box);
        showMarkers = OnlineMapsEditor.Foldout(showMarkers, string.Format("3D markers (Count: {0})", pMarkers3D.arraySize));

        if (showMarkers)
        {
            EditorGUILayout.PropertyField(pDefault3DMarker);
            EditorGUILayout.PropertyField(pMarker3DScale);
            EditorGUILayout.PropertyField(pAllowDefaultMarkerEvents);

            int removedIndex = -1;

            EditorGUI.BeginChangeCheck();
            for (int i = 0; i < pMarkers3D.arraySize; i++)
            {
                EditorGUILayout.BeginVertical(GUI.skin.box);
                OnlineMapsMarker3DPropertyDrawer.isRemoved        = false;
                OnlineMapsMarker3DPropertyDrawer.isEnabledChanged = null;

                EditorGUILayout.PropertyField(pMarkers3D.GetArrayElementAtIndex(i), new GUIContent("Marker " + (i + 1)));

                if (OnlineMapsMarker3DPropertyDrawer.isRemoved)
                {
                    removedIndex = i;
                }
                if (OnlineMapsMarker3DPropertyDrawer.isEnabledChanged.HasValue)
                {
                    control.markers3D[i].enabled = OnlineMapsMarker3DPropertyDrawer.isEnabledChanged.Value;
                }

                EditorGUILayout.EndHorizontal();
            }
            if (EditorGUI.EndChangeCheck())
            {
                dirty = true;
            }

            if (removedIndex != -1)
            {
                ArrayUtility.RemoveAt(ref control.markers3D, removedIndex);
                dirty = true;
            }

            EditorGUILayout.Space();

            if (GUILayout.Button("Add Marker"))
            {
                if (!Application.isPlaying)
                {
                    OnlineMapsMarker3D marker = new OnlineMapsMarker3D
                    {
                        position = control.GetComponent <OnlineMaps>().position,
                        scale    = pMarker3DScale.floatValue
                    };
                    ArrayUtility.Add(ref control.markers3D, marker);
                }
                else
                {
                    GameObject prefab = GameObject.CreatePrimitive(PrimitiveType.Cube);
                    control.AddMarker3D(OnlineMaps.instance.position, prefab);
                    OnlineMapsUtils.DestroyImmediate(prefab);
                }
                dirty = true;
            }
        }

        EditorGUILayout.EndVertical();
    }