Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## ? - ?

##### Additions :tada:

- Added `CesiumGoogleMapTilesRasterOverlay` to stream imagery from Google Maps.
- Added `assetOptions` to `CesiumIonRasterOverlay` to pass JSON-string options to Cesium ion as it accesses an asset.

## v1.18.1 - 2025-10-01

This release updates [cesium-native](https://github.com/CesiumGS/cesium-native) from v0.51.0 to v0.52.1. See the [changelog](https://github.com/CesiumGS/cesium-native/blob/main/CHANGES.md) for a complete list of changes in cesium-native.
Expand Down
7 changes: 7 additions & 0 deletions CONTRIBUTING.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

166 changes: 166 additions & 0 deletions Editor/CesiumGoogleMapTilesRasterOverlayEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
using UnityEditor;
using UnityEngine;

namespace CesiumForUnity
{
[CustomEditor(typeof(CesiumGoogleMapTilesRasterOverlay))]
public class CesiumGoogleMapTilesRasterOverlayEditor : Editor
{
private CesiumRasterOverlayEditor _rasterOverlayEditor;

private SerializedProperty _apiKey;
private SerializedProperty _mapType;
private SerializedProperty _language;
private SerializedProperty _region;
private SerializedProperty _scale;
private SerializedProperty _highDpi;
private SerializedProperty _layerTypes;
private SerializedProperty _styles;
private SerializedProperty _overlay;

private string[] _scaleOptions;
private int _selectedScaleIndex;

private void OnEnable()
{
this._rasterOverlayEditor =
(CesiumRasterOverlayEditor)Editor.CreateEditor(
this.target,
typeof(CesiumRasterOverlayEditor));

this._apiKey = this.serializedObject.FindProperty("_apiKey");
this._mapType = this.serializedObject.FindProperty("_mapType");
this._language = this.serializedObject.FindProperty("_language");
this._region = this.serializedObject.FindProperty("_region");
this._scale = this.serializedObject.FindProperty("_scale");
this._highDpi = this.serializedObject.FindProperty("_highDpi");
this._layerTypes = this.serializedObject.FindProperty("_layerTypes");
this._styles = this.serializedObject.FindProperty("_styles");
this._overlay = this.serializedObject.FindProperty("_overlay");

// Remove "ScaleFactor" prefix from the Scale enum options.
int nameOffset = ("ScaleFactor").Length;
this._scaleOptions = this._scale.enumNames;
for (int i = 0; i < this._scaleOptions.Length; i++)
{
this._scaleOptions[i] = this._scaleOptions[i].Substring(nameOffset);
}
this._selectedScaleIndex = this._scale.enumValueIndex;
}

private void OnDisable()
{
if (this._rasterOverlayEditor != null)
{
DestroyImmediate(this._rasterOverlayEditor);
}
}

public override void OnInspectorGUI()
{
this.serializedObject.Update();

EditorGUIUtility.labelWidth = CesiumEditorStyle.inspectorLabelWidth;
this.DrawGoogleMapTilesProperties();
EditorGUILayout.Space(5);
this.DrawRasterOverlayProperties();

this.serializedObject.ApplyModifiedProperties();
}

private void DrawGoogleMapTilesProperties()
{
GUIContent apiKeyContent = new GUIContent(
"API Key",
"The Google Map Tiles API key to use.");
EditorGUILayout.DelayedTextField(this._apiKey, apiKeyContent);

GUIContent mapTypeContent = new GUIContent(
"Map Type",
"The type of base map.");
EditorGUILayout.PropertyField(this._mapType, mapTypeContent);

GUIContent languageContent = new GUIContent(
"Language",
"An IETF language tag that specifies the language used to display " +
"information on the tiles. For example, `en-US` specifies the " +
"English language as spoken in the United States.");
EditorGUILayout.DelayedTextField(this._language, languageContent);

GUIContent regionContent = new GUIContent(
"Region",
"A Common Locale Data Repository region identifier (two uppercase " +
"letters) that represents the physical location of the user. For " +
"example, `US`.");
EditorGUILayout.DelayedTextField(this._region, regionContent);

GUIContent scaleContent = new GUIContent(
"Scale",
"Scales-up the size of map elements (such as road labels), while " +
"retaining the tile size and coverage area of the default tile." +
"\n\n" +
"Increasing the scale also reduces the number of labels on the map, " +
"which reduces clutter.");
this._selectedScaleIndex =
EditorGUILayout.Popup(scaleContent, this._selectedScaleIndex, this._scaleOptions);
this._scale.enumValueIndex = this._selectedScaleIndex;

GUIContent highDpiContent = new GUIContent(
"High DPI",
"Specifies whether to return high-resolution tiles." +
"\n\n" +
"If the scale-factor is increased, High DPI is used to increase the " +
"size of the tile. Normally, increasing the scale factor enlarges the " +
"resulting tile into an image of the same size, which lowers quality. " +
"With High DPI, the resulting size is also increased, preserving quality. " +
"DPI stands for Dots per Inch, and High DPI means the tile renders using " +
"more dots per inch than normal." +
"\n\n" +
"If enabled, the number of pixels in each of the x and y dimensions is " +
"multiplied by the scale factor (that is, 2x or 4x). The coverage area " +
"of the tile remains unchanged. This parameter works only with Scale " +
"values of 2x or 4x. It has no effect on 1x scale tiles.");
EditorGUILayout.PropertyField(this._highDpi, highDpiContent);

GUIContent layerTypesContent = new GUIContent(
"Layer Types",
"The layer types to be added to the map.");
EditorGUILayout.PropertyField(this._layerTypes, layerTypesContent);

GUIContent stylesContent = new GUIContent(
"Styles",
"A list of JSON style objects that specify the appearance and detail " +
"level of map features such as roads, parks, and built-up areas." +
"\n\n" +
"Styling is used to customize the standard Google base map. The Styles " +
"parameter is valid only if the Map Type is Roadmap.");
EditorGUILayout.PropertyField(this._styles, stylesContent);

GUIContent overlayContent = new GUIContent(
"Overlay",
"Specifies whether Layer Types are rendered as a separate overlay, or " +
"combined with the base imagery." +
"\n\n" +
"When enabled, the base map isn't displayed. If you haven't defined any " +
"Layer Types, then this value is ignored.");
EditorGUILayout.PropertyField(this._overlay, overlayContent);

GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (EditorGUILayout.LinkButton("Maps Tile API Style reference"))
{
Application.OpenURL("https://developers.google.com/maps/documentation/tile/style-reference");
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}

private void DrawRasterOverlayProperties()
{
if (this._rasterOverlayEditor != null)
{
this._rasterOverlayEditor.OnInspectorGUI();
}
}
}
}
11 changes: 11 additions & 0 deletions Editor/CesiumGoogleMapTilesRasterOverlayEditor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Editor/CesiumIonRasterOverlayEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class CesiumIonRasterOverlayEditor : Editor
private SerializedProperty _ionAssetID;
private SerializedProperty _ionAccessToken;
private SerializedProperty _ionServer;
private SerializedProperty _assetOptions;

private void OnEnable()
{
Expand All @@ -24,6 +25,7 @@ private void OnEnable()
this._ionAssetID = this.serializedObject.FindProperty("_ionAssetID");
this._ionAccessToken = this.serializedObject.FindProperty("_ionAccessToken");
this._ionServer = this.serializedObject.FindProperty("_ionServer");
this._assetOptions = this.serializedObject.FindProperty("_assetOptions");
}

private void OnDisable()
Expand Down Expand Up @@ -74,6 +76,12 @@ private void DrawIonProperties()

GUIContent ionServerContent = new GUIContent("ion Server", "The Cesium ion server to use.");
EditorGUILayout.PropertyField(this._ionServer, ionServerContent);

GUIContent assetOptionsContent = new GUIContent(
"Asset Options",
"Extra options to pass to Cesium ion when accessing the asset. " +
"This should be a JSON string.");
EditorGUILayout.DelayedTextField(this._assetOptions, assetOptionsContent);
}

private void DrawRasterOverlayProperties()
Expand Down
2 changes: 1 addition & 1 deletion Runtime/CesiumCreditSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ internal IEnumerator LoadImage(string url)
Debug.Log("Credit image could not be loaded into Texture2D.");
}
}
catch (FormatException e)
catch (FormatException)
{
Debug.Log("Could not parse credit image from base64 string.");
}
Expand Down
Loading