Cesium for Unity 1.19.0
Loading...
Searching...
No Matches
CesiumIonRasterOverlay.cs
Go to the documentation of this file.
1using Reinterop;
2using System.Collections;
3using UnityEngine;
4
5namespace CesiumForUnity
6{
10 [ReinteropNativeImplementation("CesiumForUnityNative::CesiumIonRasterOverlayImpl", "CesiumIonRasterOverlayImpl.h")]
11 [AddComponentMenu("Cesium/Cesium Ion Raster Overlay")]
12 [IconAttribute("Packages/com.cesium.unity/Editor/Resources/Cesium-24x24.png")]
13 public partial class CesiumIonRasterOverlay : CesiumRasterOverlay, ISerializationCallbackReceiver
14 {
15 [SerializeField]
16 private long _ionAssetID = 0;
17
21 public long ionAssetID
22 {
23 get => this._ionAssetID;
24 set
25 {
26 this._ionAssetID = value;
27 this.Refresh();
28 }
29 }
30
31 [SerializeField]
32 private string _ionAccessToken = "";
33
37 public string ionAccessToken
38 {
39 get => this._ionAccessToken;
40 set
41 {
42 this._ionAccessToken = value;
43 this.Refresh();
44 }
45 }
46
47 [SerializeField]
48 private CesiumIonServer _ionServer = null;
49
54 {
55 get
56 {
57 if (this._ionServer == null)
58 {
59#if UNITY_EDITOR
60 // See OnAfterDeserialize.
61 if (this._useDefaultServer)
62 this._ionServer = CesiumIonServer.defaultServer;
63 else
64 this._ionServer = CesiumIonServer.serverForNewObjects;
65
66 this._useDefaultServer = false;
67#else
68 this._ionServer = CesiumIonServer.serverForNewObjects;
69#endif
70 }
71 return this._ionServer;
72 }
73 set
74 {
75 if (value == null) value = CesiumIonServer.serverForNewObjects;
76 this._ionServer = value;
77 this.Refresh();
78 }
79 }
80
81 [SerializeField]
82 private string _assetOptions = "";
83
88 public string assetOptions
89 {
90 get => this._assetOptions;
91 set
92 {
93 this._assetOptions = value;
94 this.Refresh();
95 }
96 }
97
99 protected override partial void AddToTileset(Cesium3DTileset tileset);
101 protected override partial void RemoveFromTileset(Cesium3DTileset tileset);
102
103 internal IEnumerator AddToTilesetLater(Cesium3DTileset tileset)
104 {
105 yield return new WaitForSecondsRealtime(0.1f);
106 this.AddToTileset(tileset);
107 }
108
109 void ISerializationCallbackReceiver.OnBeforeSerialize()
110 {
111 }
112
113 void ISerializationCallbackReceiver.OnAfterDeserialize()
114 {
115#if UNITY_EDITOR
116 // For backward compatibility, overlays loaded without a server should adopt
117 // the default one rather than the current one.
118 if (this._ionServer == null)
119 this._useDefaultServer = true;
120#endif
121 }
122
123#if UNITY_EDITOR
124 private bool _useDefaultServer = false;
125#endif
126 }
127}
A tileset in the 3D Tiles format.
A CesiumRasterOverlay that uses an IMAGERY asset from Cesium ion.
override partial void RemoveFromTileset(Cesium3DTileset tileset)
string assetOptions
Extra options to pass to Cesium ion when accessing the asset.
long ionAssetID
The ID of the Cesium ion asset to use.
override partial void AddToTileset(Cesium3DTileset tileset)
CesiumIonServer ionServer
The Cesium ion server from which this raster overlay is loaded.
string ionAccessToken
The access token to use to access the Cesium ion resource.
Defines a Cesium ion Server.
static CesiumIonServer serverForNewObjects
Gets the current Cesium ion server that should be assigned to newly-created objects.
static CesiumIonServer defaultServer
Gets the default Cesium ion Server (ion.cesium.com).
A pyramid of 2D images - sometimes terabytes or more in size - that can be draped over a Cesium3DTile...
void Refresh()
Refreshes this overlay by calling RemoveFromTileset followed by AddToTileset.
void AddToTileset()
Adds this raster overlay to the Cesium3DTileset on the same game object.