Cesium for Unity 1.15.2
Loading...
Searching...
No Matches
CesiumIonServer.cs
Go to the documentation of this file.
1using System.ComponentModel;
2using UnityEditor;
3using UnityEngine;
4
5namespace CesiumForUnity
6{
11 [CreateAssetMenu(fileName = "CesiumIonServer", menuName = "Cesium/Cesium ion Server")]
12 [AddComponentMenu("Cesium/Cesium ion Server")]
13 public class CesiumIonServer : ScriptableObject
14 {
19 public string serverUrl = "https://ion.cesium.com";
20
26 public string apiUrl = "https://api.cesium.com";
27
33 public long oauth2ApplicationID = 381;
34
41 public string defaultIonAccessTokenId = "";
42
47 public string defaultIonAccessToken = "";
48
49 // The server URL for which we are currently attempting to deduce an API URL. When this property
50 // is null, we're not currently loading a config.json in order to deduce an API URL for the server.
51 // When this property is different from `serverUrl`, a config.json load is in progress, but it's
52 // obsolete.
53 internal string serverUrlThatIsLoadingApiUrl = null;
54
65 {
66 get
67 {
68#if UNITY_EDITOR
69 CesiumIonServer result = AssetDatabase.LoadAssetAtPath(
70 "Assets/CesiumSettings/Resources/CesiumIonServers/ion.cesium.com.asset",
72#else
73 CesiumIonServer result = Resources.Load<CesiumIonServer>("CesiumIonServers/ion.cesium.com");
74#endif
75
76#if UNITY_EDITOR
77 if (result == null)
78 {
79 if (!AssetDatabase.IsValidFolder("Assets/CesiumSettings"))
80 AssetDatabase.CreateFolder("Assets", "CesiumSettings");
81 if (!AssetDatabase.IsValidFolder("Assets/CesiumSettings/Resources"))
82 AssetDatabase.CreateFolder("Assets/CesiumSettings", "Resources");
83 if (!AssetDatabase.IsValidFolder("Assets/CesiumSettings/Resources/CesiumIonServers"))
84 AssetDatabase.CreateFolder("Assets/CesiumSettings/Resources", "CesiumIonServers");
85 result = ScriptableObject.CreateInstance<CesiumIonServer>();
86
87#pragma warning disable 618
88 if (!string.IsNullOrEmpty(CesiumRuntimeSettings.defaultIonAccessTokenID))
89 {
90 if (string.IsNullOrEmpty(result.defaultIonAccessTokenId))
91 {
92 result.defaultIonAccessTokenId = CesiumRuntimeSettings.defaultIonAccessTokenID;
93 }
94 CesiumRuntimeSettings.defaultIonAccessTokenID = "";
95 }
96
97 if (!string.IsNullOrEmpty(CesiumRuntimeSettings.defaultIonAccessToken))
98 {
99 if (string.IsNullOrEmpty(result.defaultIonAccessToken))
100 {
101 result.defaultIonAccessToken = CesiumRuntimeSettings.defaultIonAccessToken;
102 }
103 CesiumRuntimeSettings.defaultIonAccessToken = "";
104 }
105
106#pragma warning restore 618
107
108 AssetDatabase.CreateAsset(result, "Assets/CesiumSettings/Resources/CesiumIonServers/ion.cesium.com.asset");
109 AssetDatabase.Refresh();
110 }
111#endif
112
113 return result;
114 }
115 }
116
121 {
122 get
123 {
124 if (_serverForNewObjects == null)
125 return defaultServer;
126 else
127 return _serverForNewObjects;
128 }
129 set
130 {
131 _serverForNewObjects = value;
132 }
133 }
134
135 private static CesiumIonServer _serverForNewObjects;
136 }
137}
Defines a Cesium ion Server.
string apiUrl
The URL of the main API endpoint of the Cesium ion server.
long oauth2ApplicationID
The application ID to use to log in to this server using OAuth2.
static CesiumIonServer serverForNewObjects
Gets the current Cesium ion server that should be assigned to newly-created objects.
string serverUrl
The main URL of the Cesium ion server.
string defaultIonAccessToken
The default token used to access Cesium ion assets at runtime.
string defaultIonAccessTokenId
The ID of the default access token to use to access Cesium ion assets at runtime.
static CesiumIonServer defaultServer
Gets the default Cesium ion Server (ion.cesium.com).
Holds Cesium settings used at runtime.
static string defaultIonAccessToken
The default Cesium ion access token value to use within the project.
static string defaultIonAccessTokenID
The ID of the default Cesium ion access token to use within the project.