|
| 1 | +using UnityEditor; |
| 2 | +using UnityEngine; |
| 3 | + |
| 4 | +namespace CesiumForUnity |
| 5 | +{ |
| 6 | + [CustomEditor(typeof(CesiumAzureMapsRasterOverlay))] |
| 7 | + public class CesiumAzureMapsRasterOverlayEditor : Editor |
| 8 | + { |
| 9 | + private CesiumRasterOverlayEditor _rasterOverlayEditor; |
| 10 | + |
| 11 | + private SerializedProperty _key; |
| 12 | + private SerializedProperty _apiVersion; |
| 13 | + private SerializedProperty _tilesetId; |
| 14 | + private SerializedProperty _language; |
| 15 | + private SerializedProperty _view; |
| 16 | + |
| 17 | + private void OnEnable() |
| 18 | + { |
| 19 | + this._rasterOverlayEditor = |
| 20 | + (CesiumRasterOverlayEditor)Editor.CreateEditor( |
| 21 | + this.target, |
| 22 | + typeof(CesiumRasterOverlayEditor)); |
| 23 | + |
| 24 | + this._key = this.serializedObject.FindProperty("_key"); |
| 25 | + this._apiVersion = this.serializedObject.FindProperty("_apiVersion"); |
| 26 | + this._tilesetId = this.serializedObject.FindProperty("_tilesetId"); |
| 27 | + this._language = this.serializedObject.FindProperty("_language"); |
| 28 | + this._view = this.serializedObject.FindProperty("_view"); |
| 29 | + } |
| 30 | + |
| 31 | + private void OnDisable() |
| 32 | + { |
| 33 | + if (this._rasterOverlayEditor != null) |
| 34 | + { |
| 35 | + DestroyImmediate(this._rasterOverlayEditor); |
| 36 | + } |
| 37 | + } |
| 38 | + |
| 39 | + public override void OnInspectorGUI() |
| 40 | + { |
| 41 | + this.serializedObject.Update(); |
| 42 | + this._rasterOverlayEditor?.DrawInspectorButtons(); |
| 43 | + EditorGUIUtility.labelWidth = CesiumEditorStyle.inspectorLabelWidth; |
| 44 | + this.DrawAzureMapsProperties(); |
| 45 | + EditorGUILayout.Space(5); |
| 46 | + this.DrawRasterOverlayProperties(); |
| 47 | + this.serializedObject.ApplyModifiedProperties(); |
| 48 | + } |
| 49 | + |
| 50 | + private void DrawAzureMapsProperties() |
| 51 | + { |
| 52 | + var keyContent = new GUIContent( |
| 53 | + "Key", |
| 54 | + "The Azure Maps key to use."); |
| 55 | + EditorGUILayout.DelayedTextField(this._key, keyContent); |
| 56 | + |
| 57 | + var apiVersionContent = new GUIContent( |
| 58 | + "API Version", |
| 59 | + "The Azure Maps API version to use."); |
| 60 | + EditorGUILayout.PropertyField(this._apiVersion, apiVersionContent); |
| 61 | + |
| 62 | + var tileSetIdContent = new GUIContent( |
| 63 | + "Tile Set ID", |
| 64 | + "The Azure tile set ID to use."); |
| 65 | + EditorGUILayout.PropertyField(this._tilesetId, tileSetIdContent); |
| 66 | + |
| 67 | + var languageContent = new GUIContent( |
| 68 | + "Language", |
| 69 | + "The language in which search results should be returned. This should be one" |
| 70 | + + " of the supported IETF language tags, case insensitive. When data in the" |
| 71 | + + " specified language is not available for a specific field, default language"); |
| 72 | + EditorGUILayout.PropertyField(this._language, languageContent); |
| 73 | + |
| 74 | + var viewContent = new GUIContent( |
| 75 | + "View", |
| 76 | + "The View parameter (also called the \"user region\" parameter) allows " |
| 77 | + +"you to show the correct maps for a certain country/region for " |
| 78 | + +"geopolitically disputed regions. " |
| 79 | + +"\n" |
| 80 | + +"Different countries/regions have different views of such regions, and the " |
| 81 | + +"View parameter allows your application to comply with the view required by " |
| 82 | + +"the country/region your application will be serving. By default, the View " |
| 83 | + +"parameter is set to \"Unified\" even if you haven't defined it in the " |
| 84 | + +"request. It is your responsibility to determine the location of your users, " |
| 85 | + +"and then set the View parameter correctly for that location. Alternatively, " |
| 86 | + +"you have the option to set 'View=Auto', which will return the map data " |
| 87 | + +"based on the IP address of the request. The View parameter in Azure Maps " |
| 88 | + +"must be used in compliance with applicable laws, including those regarding " |
| 89 | + +"mapping, of the country/region where maps, images and other data and third " |
| 90 | + +"party content that you are authorized to access via Azure Maps is made " |
| 91 | + +"available. Example: view=IN."); |
| 92 | + EditorGUILayout.PropertyField(this._view, viewContent); |
| 93 | + } |
| 94 | + |
| 95 | + private void DrawRasterOverlayProperties() => this._rasterOverlayEditor?.OnInspectorGUI(); |
| 96 | + } |
| 97 | +} |
0 commit comments