Cesium for Unity 1.15.2
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
82 protected override partial void AddToTileset(Cesium3DTileset tileset);
84 protected override partial void RemoveFromTileset(Cesium3DTileset tileset);
85
86 internal IEnumerator AddToTilesetLater(Cesium3DTileset tileset)
87 {
88 yield return new WaitForSecondsRealtime(0.1f);
89 this.AddToTileset(tileset);
90 }
91
92 void ISerializationCallbackReceiver.OnBeforeSerialize()
93 {
94 }
95
96 void ISerializationCallbackReceiver.OnAfterDeserialize()
97 {
98#if UNITY_EDITOR
99 // For backward compatibility, overlays loaded without a server should adopt
100 // the default one rather than the current one.
101 if (this._ionServer == null)
102 this._useDefaultServer = true;
103#endif
104 }
105
106#if UNITY_EDITOR
107 private bool _useDefaultServer = false;
108#endif
109 }
110}
A tileset in the 3D Tiles format.
A CesiumRasterOverlay that uses an IMAGERY asset from Cesium ion.
override partial void RemoveFromTileset(Cesium3DTileset tileset)
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.