FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
DISForUnityExample/Assets/CesiumKeyLoader.cs at github · AF-GRILL/DISForUnityExample · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
AF-GRILL
/
DISForUnityExample
Public
Notifications
You must be signed in to change notification settings
Fork
2
Star
7
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
DISForUnityExample
/
Assets
/
CesiumKeyLoader.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
94 lines (77 loc) · 2.92 KB
Breadcrumbs
DISForUnityExample
/
Assets
/
CesiumKeyLoader.cs
Copy path
File metadata and controls
94 lines (77 loc) · 2.92 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using
System
.
Collections
;
using
System
.
Collections
.
Generic
;
using
UnityEngine
;
using
CesiumForUnity
;
using
System
;
public
class
CesiumIonData
{
public
string
WorldTerrainCesiumURL
;
public
string
WorldTerrainCesiumIonToken
;
public
long
WorldTerrainCesiumIonAssetID
;
public
string
RasterOverlayCesiumURL
;
public
string
RasterOverlayCesiumIonToken
;
public
long
RasterOverlayCesiumIonAssetID
;
}
public
class
CesiumKeyLoader
:
MonoBehaviour
{
private
Cesium3DTileset
cesium3DTilesetScript
;
private
CesiumIonRasterOverlay
cesiumRasterOverlayScript
;
private
CesiumIonData
cesiumIonData
;
// Start is called before the first frame update
void
Start
(
)
{
if
(
ReadCesiumIonInfoFile
(
)
)
{
cesium3DTilesetScript
=
GetComponentInChildren
<
Cesium3DTileset
>
(
)
;
cesiumRasterOverlayScript
=
GetComponentInChildren
<
CesiumIonRasterOverlay
>
(
)
;
UpdateCesiumTileset
(
)
;
UpdateCesiumRasterOverlay
(
)
;
}
}
bool
ReadCesiumIonInfoFile
(
)
{
TextAsset
CesiumIonInfoFile
=
Resources
.
Load
(
"CesiumIonInfo"
)
as
TextAsset
;
string
json
=
CesiumIonInfoFile
.
text
;
if
(
string
.
IsNullOrEmpty
(
json
)
)
{
Debug
.
LogError
(
"The CesiumIonInfo.txt file in the Resources folder is empty. Refer to project README on how to properly fill it out."
)
;
return
false
;
}
try
{
cesiumIonData
=
JsonUtility
.
FromJson
<
CesiumIonData
>
(
json
)
;
return
true
;
}
catch
(
ArgumentException
ex
)
{
Debug
.
LogError
(
"Issue with the CesiumIonInfo.txt file in the Resources folder. Refer to project README on how to properly fill it out.
\n
Error: "
+
ex
.
Message
)
;
return
false
;
}
}
void
UpdateCesiumTileset
(
)
{
cesium3DTilesetScript
.
tilesetSource
=
(
string
.
IsNullOrEmpty
(
cesiumIonData
.
WorldTerrainCesiumURL
)
)
?
CesiumDataSource
.
FromCesiumIon
:
CesiumDataSource
.
FromUrl
;
switch
(
cesium3DTilesetScript
.
tilesetSource
)
{
case
CesiumDataSource
.
FromCesiumIon
:
cesium3DTilesetScript
.
ionAssetID
=
cesiumIonData
.
WorldTerrainCesiumIonAssetID
;
cesium3DTilesetScript
.
ionAccessToken
=
cesiumIonData
.
WorldTerrainCesiumIonToken
;
break
;
case
CesiumDataSource
.
FromUrl
:
cesium3DTilesetScript
.
url
=
cesiumIonData
.
WorldTerrainCesiumURL
;
break
;
default
:
break
;
}
cesium3DTilesetScript
.
RecreateTileset
(
)
;
}
void
UpdateCesiumRasterOverlay
(
)
{
if
(
string
.
IsNullOrEmpty
(
cesiumIonData
.
RasterOverlayCesiumURL
)
)
{
cesiumRasterOverlayScript
.
ionAccessToken
=
cesiumIonData
.
RasterOverlayCesiumIonToken
;
cesiumRasterOverlayScript
.
ionAssetID
=
cesiumIonData
.
RasterOverlayCesiumIonAssetID
;
cesium3DTilesetScript
.
RecreateTileset
(
)
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL