예제 #1
0
    public void buildMap()
    {
        serializedObject.Update();

        GUILayout.BeginHorizontal();
        EditorGUILayout.PropertyField(serializedObject.FindProperty("ApiKey"));
        if (GUILayout.Button("Get an API key", EditorStyles.miniButtonRight))
        {
            Application.OpenURL("https://developers.nextzen.org/");
        }
        GUILayout.EndHorizontal();

        EditorGUILayout.PropertyField(serializedObject.FindProperty("Style"), true);

        EditorGUILayout.PropertyField(serializedObject.FindProperty("Area"), true);

        EditorGUILayout.PropertyField(serializedObject.FindProperty("UnitsPerMeter"));

        EditorGUILayout.PropertyField(serializedObject.FindProperty("RegionName"));

        map.GroupOptions = (SceneGroupType)EditorGUILayout.EnumFlagsField("Grouping Options", map.GroupOptions);

        // EditorGUILayout.PropertyField(serializedObject.FindProperty("GroupOptions"));

        EditorGUILayout.PropertyField(serializedObject.FindProperty("GameObjectOptions"), true);

        bool valid = map.IsValid();


        if (GUILayout.Button("Download"))
        {
            map.LogWarnings();
            Debug.Log("Download Button is pressed");
            if (valid)
            {
                map.DownloadTilesAsync();
            }
            else
            {
                map.LogErrors();
            }
        }

        if (map.HasPendingTasks())
        {
            // Go through another OnInspectorGUI cycle
            Repaint();

            if (map.FinishedRunningTasks())
            {
                map.GenerateSceneGraph();
            }
        }



        serializedObject.ApplyModifiedProperties();
    }
예제 #2
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            MapStyle mapStyle = serializedObject.targetObject as MapStyle;

            if (mapStyle == null)
            {
                // ????
                return;
            }

            GUILayout.Label("Editing options", labelBoldStyle);

            var liveUpdateProperty = serializedObject.FindProperty("liveUpdateEnabled");

            EditorGUILayout.PropertyField(liveUpdateProperty, new GUIContent {
                text = "Update RegionMap while editing"
            });

            GUILayout.Space(EditorGUIUtility.singleLineHeight);

            GUILayout.Label("Layers", labelBoldStyle);

            layerTreeView.Layers = mapStyle.Layers;
            layerTreeView.Reload();
            layerTreeView.OnGUI(GUILayoutUtility.GetRect(0, 500, 0, 150));

            var selectedLayers = layerTreeView.GetSelection();

            var layerArrayProperty = serializedObject.FindProperty("Layers");

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Add Layer"))
            {
                mapStyle.Layers.Add(new FeatureLayer("untitled"));
            }
            if (GUILayout.Button("Remove Selected"))
            {
                foreach (var index in selectedLayers.OrderByDescending(i => i))
                {
                    layerArrayProperty.DeleteArrayElementAtIndex(index);
                }
                selectedLayers = new int[0];
                layerTreeView.SetSelection(selectedLayers);
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(EditorGUIUtility.singleLineHeight);

            if (selectedLayers.Count == 1)
            {
                var index = selectedLayers[0];

                var layerProperty = layerArrayProperty.GetArrayElementAtIndex(index);

                layerProperty.isExpanded = true;

                GUILayout.Label("Layer Properties", labelBoldStyle);

                var layer = mapStyle.Layers[index];

                layer.FeatureCollection = (FeatureLayer.MapzenFeatureCollection)EditorGUILayout.EnumFlagsField("Feature Collections", layer.FeatureCollection);

                DrawSelectedLayer(layerProperty);
            }
            else
            {
                GUILayout.Label("Select a layer to see properties", labelItalicCenteredStyle);
            }

            serializedObject.ApplyModifiedProperties();

            if (liveUpdateProperty.boolValue)
            {
                // Find the regionMap containing the style mapStyle
                var       regionMaps = GameObject.FindObjectsOfType <RegionMap>();
                RegionMap map        = null;
                foreach (var regionMap in regionMaps)
                {
                    if (regionMap.Style == mapStyle)
                    {
                        map = regionMap;
                        break;
                    }
                }

                if (map != null)
                {
                    if (GUI.changed)
                    {
                        map.LogWarnings();
                        if (map.IsValid())
                        {
                            map.DownloadTilesAsync();
                        }
                        else
                        {
                            map.LogErrors();
                        }
                    }

                    if (map.HasPendingTasks())
                    {
                        Repaint();
                        if (map.FinishedRunningTasks())
                        {
                            map.GenerateSceneGraph();
                        }
                    }
                }
            }
        }
예제 #3
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            GUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("ApiKey"));
            if (GUILayout.Button("Get an API key", EditorStyles.miniButtonRight))
            {
                Application.OpenURL("https://mapzen.com/developers");
            }
            GUILayout.EndHorizontal();

            EditorGUILayout.PropertyField(serializedObject.FindProperty("Style"), true);

            EditorGUILayout.PropertyField(serializedObject.FindProperty("Area"), true);

            EditorGUILayout.PropertyField(serializedObject.FindProperty("UnitsPerMeter"));

            EditorGUILayout.PropertyField(serializedObject.FindProperty("RegionName"));

            map.GroupOptions = (SceneGroupType)EditorGUILayout.EnumMaskPopup("Grouping Options", map.GroupOptions);

            // EditorGUILayout.PropertyField(serializedObject.FindProperty("GroupOptions"));

            EditorGUILayout.PropertyField(serializedObject.FindProperty("GameObjectOptions"), true);

            bool valid = map.IsValid();

            EditorConfig.SetColor(valid ?
                                  EditorConfig.DownloadButtonEnabledColor :
                                  EditorConfig.DownloadButtonDisabledColor);

            if (GUILayout.Button("Download"))
            {
                map.LogWarnings();

                if (valid)
                {
                    map.DownloadTilesAsync();
                }
                else
                {
                    map.LogErrors();
                }
            }

            if (map.HasPendingTasks())
            {
                // Go through another OnInspectorGUI cycle
                Repaint();

                if (map.FinishedRunningTasks())
                {
                    map.GenerateSceneGraph();
                }
            }

            EditorConfig.ResetColor();

            serializedObject.ApplyModifiedProperties();
        }