org.outernet.cesium-unity 1.15.3-linux.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGES.md +420 -0
- package/CHANGES.md.meta +7 -0
- package/Editor/BuildCesiumForUnity.cs +186 -0
- package/Editor/BuildCesiumForUnity.cs.meta +11 -0
- package/Editor/Cesium3DTilesetEditor.cs +542 -0
- package/Editor/Cesium3DTilesetEditor.cs.meta +11 -0
- package/Editor/CesiumBingMapsRasterOverlayEditor.cs +66 -0
- package/Editor/CesiumBingMapsRasterOverlayEditor.cs.meta +11 -0
- package/Editor/CesiumCameraControllerEditor.cs +174 -0
- package/Editor/CesiumCameraControllerEditor.cs.meta +11 -0
- package/Editor/CesiumCameraManagerEditor.cs +65 -0
- package/Editor/CesiumCameraManagerEditor.cs.meta +11 -0
- package/Editor/CesiumCartographicPolygonEditor.cs +23 -0
- package/Editor/CesiumCartographicPolygonEditor.cs.meta +11 -0
- package/Editor/CesiumDebugColorizeTilesRasterOverlayEditor.cs +41 -0
- package/Editor/CesiumDebugColorizeTilesRasterOverlayEditor.cs.meta +11 -0
- package/Editor/CesiumEditor.asmdef +26 -0
- package/Editor/CesiumEditor.asmdef.meta +7 -0
- package/Editor/CesiumEditorStyle.cs +188 -0
- package/Editor/CesiumEditorStyle.cs.meta +11 -0
- package/Editor/CesiumEditorUtility.cs +394 -0
- package/Editor/CesiumEditorUtility.cs.meta +11 -0
- package/Editor/CesiumEditorWindow.cs +447 -0
- package/Editor/CesiumEditorWindow.cs.meta +11 -0
- package/Editor/CesiumFlyToControllerEditor.cs +76 -0
- package/Editor/CesiumFlyToControllerEditor.cs.meta +11 -0
- package/Editor/CesiumGeoreferenceEditor.cs +277 -0
- package/Editor/CesiumGeoreferenceEditor.cs.meta +11 -0
- package/Editor/CesiumGlobeAnchorEditor.cs +202 -0
- package/Editor/CesiumGlobeAnchorEditor.cs.meta +11 -0
- package/Editor/CesiumInspectorGUI.cs +187 -0
- package/Editor/CesiumInspectorGUI.cs.meta +11 -0
- package/Editor/CesiumIonAsset.cs +192 -0
- package/Editor/CesiumIonAsset.cs.meta +11 -0
- package/Editor/CesiumIonAssetsWindow.cs +257 -0
- package/Editor/CesiumIonAssetsWindow.cs.meta +11 -0
- package/Editor/CesiumIonRasterOverlayEditor.cs +87 -0
- package/Editor/CesiumIonRasterOverlayEditor.cs.meta +11 -0
- package/Editor/CesiumIonServerManager.cs +153 -0
- package/Editor/CesiumIonServerManager.cs.meta +11 -0
- package/Editor/CesiumIonServerSelector.cs +127 -0
- package/Editor/CesiumIonServerSelector.cs.meta +11 -0
- package/Editor/CesiumIonSession.cs +102 -0
- package/Editor/CesiumIonSession.cs.meta +11 -0
- package/Editor/CesiumPolygonRasterOverlayEditor.cs +102 -0
- package/Editor/CesiumPolygonRasterOverlayEditor.cs.meta +11 -0
- package/Editor/CesiumRasterOverlayEditor.cs +230 -0
- package/Editor/CesiumRasterOverlayEditor.cs.meta +11 -0
- package/Editor/CesiumSubSceneEditor.cs +201 -0
- package/Editor/CesiumSubSceneEditor.cs.meta +11 -0
- package/Editor/CesiumTileMapServiceRasterOverlayEditor.cs +88 -0
- package/Editor/CesiumTileMapServiceRasterOverlayEditor.cs.meta +11 -0
- package/Editor/CesiumWebMapServiceRasterOverlayEditor.cs +111 -0
- package/Editor/CesiumWebMapServiceRasterOverlayEditor.cs.meta +11 -0
- package/Editor/CesiumWebMapTileServiceRasterOverlayEditor.cs +277 -0
- package/Editor/CesiumWebMapTileServiceRasterOverlayEditor.cs.meta +3 -0
- package/Editor/CompileCesiumForUnityNative.cs +581 -0
- package/Editor/CompileCesiumForUnityNative.cs.meta +11 -0
- package/Editor/ConfigureReinterop.cs +255 -0
- package/Editor/ConfigureReinterop.cs.meta +11 -0
- package/Editor/Helpers.cs +102 -0
- package/Editor/Helpers.cs.meta +11 -0
- package/Editor/IonAssetsMultiColumnHeader.cs +45 -0
- package/Editor/IonAssetsMultiColumnHeader.cs.meta +11 -0
- package/Editor/IonAssetsTreeView.cs +214 -0
- package/Editor/IonAssetsTreeView.cs.meta +11 -0
- package/Editor/IonMissingAssetWindow.cs +65 -0
- package/Editor/IonMissingAssetWindow.cs.meta +11 -0
- package/Editor/IonTokenTroubleshootingWindow.cs +615 -0
- package/Editor/IonTokenTroubleshootingWindow.cs.meta +11 -0
- package/Editor/NativeDownloadHandler.cs +35 -0
- package/Editor/NativeDownloadHandler.cs.meta +11 -0
- package/Editor/QuickAddItem.cs +43 -0
- package/Editor/QuickAddItem.cs.meta +11 -0
- package/Editor/Resources/Cesium-128x128.png +0 -0
- package/Editor/Resources/Cesium-128x128.png.meta +98 -0
- package/Editor/Resources/Cesium-24x24.png +0 -0
- package/Editor/Resources/Cesium-24x24.png.meta +123 -0
- package/Editor/Resources/Cesium-64x64.png +0 -0
- package/Editor/Resources/Cesium-64x64.png.meta +98 -0
- package/Editor/Resources/Cesium-for-Unity-dark.png +0 -0
- package/Editor/Resources/Cesium-for-Unity-dark.png.meta +123 -0
- package/Editor/Resources/Cesium-for-Unity-light.png +0 -0
- package/Editor/Resources/Cesium-for-Unity-light.png.meta +123 -0
- package/Editor/Resources/Cesium-icon-16x16.png +0 -0
- package/Editor/Resources/Cesium-icon-16x16.png.meta +98 -0
- package/Editor/Resources/FontAwesome/attribution.txt +9 -0
- package/Editor/Resources/FontAwesome/attribution.txt.meta +7 -0
- package/Editor/Resources/FontAwesome/book-reader-solid.png +0 -0
- package/Editor/Resources/FontAwesome/book-reader-solid.png.meta +98 -0
- package/Editor/Resources/FontAwesome/book-reader-solid.svg +1 -0
- package/Editor/Resources/FontAwesome/book-reader-solid.svg.meta +7 -0
- package/Editor/Resources/FontAwesome/check-solid.png +0 -0
- package/Editor/Resources/FontAwesome/check-solid.png.meta +98 -0
- package/Editor/Resources/FontAwesome/check-solid.svg +1 -0
- package/Editor/Resources/FontAwesome/check-solid.svg.meta +7 -0
- package/Editor/Resources/FontAwesome/cloud-upload-alt-solid.png +0 -0
- package/Editor/Resources/FontAwesome/cloud-upload-alt-solid.png.meta +98 -0
- package/Editor/Resources/FontAwesome/cloud-upload-alt-solid.svg +1 -0
- package/Editor/Resources/FontAwesome/cloud-upload-alt-solid.svg.meta +7 -0
- package/Editor/Resources/FontAwesome/folder.png +0 -0
- package/Editor/Resources/FontAwesome/folder.png.meta +147 -0
- package/Editor/Resources/FontAwesome/folder.svg +5 -0
- package/Editor/Resources/FontAwesome/folder.svg.meta +7 -0
- package/Editor/Resources/FontAwesome/hands-helping-solid.png +0 -0
- package/Editor/Resources/FontAwesome/hands-helping-solid.png.meta +98 -0
- package/Editor/Resources/FontAwesome/hands-helping-solid.svg +1 -0
- package/Editor/Resources/FontAwesome/hands-helping-solid.svg.meta +7 -0
- package/Editor/Resources/FontAwesome/key-solid.png +0 -0
- package/Editor/Resources/FontAwesome/key-solid.png.meta +98 -0
- package/Editor/Resources/FontAwesome/key-solid.svg +1 -0
- package/Editor/Resources/FontAwesome/key-solid.svg.meta +7 -0
- package/Editor/Resources/FontAwesome/plus-solid.png +0 -0
- package/Editor/Resources/FontAwesome/plus-solid.png.meta +98 -0
- package/Editor/Resources/FontAwesome/plus-solid.svg +1 -0
- package/Editor/Resources/FontAwesome/plus-solid.svg.meta +7 -0
- package/Editor/Resources/FontAwesome/sign-out-alt-solid.png +0 -0
- package/Editor/Resources/FontAwesome/sign-out-alt-solid.png.meta +98 -0
- package/Editor/Resources/FontAwesome/sign-out-alt-solid.svg +1 -0
- package/Editor/Resources/FontAwesome/sign-out-alt-solid.svg.meta +7 -0
- package/Editor/Resources/FontAwesome/sync-alt-solid.png +0 -0
- package/Editor/Resources/FontAwesome/sync-alt-solid.png.meta +98 -0
- package/Editor/Resources/FontAwesome/sync-alt-solid.svg +1 -0
- package/Editor/Resources/FontAwesome/sync-alt-solid.svg.meta +7 -0
- package/Editor/Resources/FontAwesome/times-solid.png +0 -0
- package/Editor/Resources/FontAwesome/times-solid.png.meta +98 -0
- package/Editor/Resources/FontAwesome/times-solid.svg +1 -0
- package/Editor/Resources/FontAwesome/times-solid.svg.meta +7 -0
- package/Editor/Resources/FontAwesome.meta +8 -0
- package/Editor/Resources.meta +8 -0
- package/Editor/SelectIonTokenWindow.cs +249 -0
- package/Editor/SelectIonTokenWindow.cs.meta +11 -0
- package/Editor/arm64.meta +8 -0
- package/Editor/csc.rsp +1 -0
- package/Editor/csc.rsp.meta +7 -0
- package/Editor/libCesiumForUnityNative-Editor.so +0 -0
- package/Editor/libCesiumForUnityNative-Editor.so.meta +2 -0
- package/Editor/libCesiumForUnityNative-Runtime.so +0 -0
- package/Editor/libCesiumForUnityNative-Runtime.so.meta +2 -0
- package/Editor/x86_64.meta +8 -0
- package/Editor.meta +8 -0
- package/LICENSE +201 -0
- package/LICENSE.meta +7 -0
- package/Plugins/Standalone/libCesiumForUnityNative-Runtime.so +0 -0
- package/Plugins/Standalone/libCesiumForUnityNative-Runtime.so.meta +2 -0
- package/Plugins/Standalone.meta +8 -0
- package/Plugins.meta +8 -0
- package/README.md +39 -0
- package/README.md.meta +7 -0
- package/Reinterop.deps.json +172 -0
- package/Reinterop.deps.json.meta +7 -0
- package/Reinterop.dll +0 -0
- package/Reinterop.dll.meta +79 -0
- package/Runtime/Cesium3DTile.cs +37 -0
- package/Runtime/Cesium3DTile.cs.meta +11 -0
- package/Runtime/Cesium3DTileset.cs +788 -0
- package/Runtime/Cesium3DTileset.cs.meta +11 -0
- package/Runtime/Cesium3DTilesetLoadFailureDetails.cs +65 -0
- package/Runtime/Cesium3DTilesetLoadFailureDetails.cs.meta +11 -0
- package/Runtime/CesiumBackwardCompatibility.cs +163 -0
- package/Runtime/CesiumBackwardCompatibility.cs.meta +11 -0
- package/Runtime/CesiumBingMapsRasterOverlay.cs +72 -0
- package/Runtime/CesiumBingMapsRasterOverlay.cs.meta +11 -0
- package/Runtime/CesiumCameraController.cs +827 -0
- package/Runtime/CesiumCameraController.cs.meta +11 -0
- package/Runtime/CesiumCameraManager.cs +105 -0
- package/Runtime/CesiumCameraManager.cs.meta +11 -0
- package/Runtime/CesiumCartographicPolygon.cs +152 -0
- package/Runtime/CesiumCartographicPolygon.cs.meta +11 -0
- package/Runtime/CesiumCreditSystem.cs +343 -0
- package/Runtime/CesiumCreditSystem.cs.meta +11 -0
- package/Runtime/CesiumCreditSystemUI.cs +402 -0
- package/Runtime/CesiumCreditSystemUI.cs.meta +11 -0
- package/Runtime/CesiumDebugColorizeTilesRasterOverlay.cs +21 -0
- package/Runtime/CesiumDebugColorizeTilesRasterOverlay.cs.meta +11 -0
- package/Runtime/CesiumEllipsoid.cs +107 -0
- package/Runtime/CesiumEllipsoid.cs.meta +11 -0
- package/Runtime/CesiumFeature.cs +279 -0
- package/Runtime/CesiumFeature.cs.meta +11 -0
- package/Runtime/CesiumFeatureIdAttribute.cs +61 -0
- package/Runtime/CesiumFeatureIdAttribute.cs.meta +11 -0
- package/Runtime/CesiumFeatureIdSet.cs +165 -0
- package/Runtime/CesiumFeatureIdSet.cs.meta +11 -0
- package/Runtime/CesiumFeatureIdTexture.cs +68 -0
- package/Runtime/CesiumFeatureIdTexture.cs.meta +11 -0
- package/Runtime/CesiumFlyToController.cs +539 -0
- package/Runtime/CesiumFlyToController.cs.meta +11 -0
- package/Runtime/CesiumGeoreference.cs +628 -0
- package/Runtime/CesiumGeoreference.cs.meta +11 -0
- package/Runtime/CesiumGlobeAnchor.cs +664 -0
- package/Runtime/CesiumGlobeAnchor.cs.meta +11 -0
- package/Runtime/CesiumGlobeAnchorBackwardCompatibility0dot2dot0.cs +105 -0
- package/Runtime/CesiumGlobeAnchorBackwardCompatibility0dot2dot0.cs.meta +11 -0
- package/Runtime/CesiumIntMatN.cs +398 -0
- package/Runtime/CesiumIntMatN.cs.meta +11 -0
- package/Runtime/CesiumIntVecN.cs +525 -0
- package/Runtime/CesiumIntVecN.cs.meta +11 -0
- package/Runtime/CesiumIonRasterOverlay.cs +110 -0
- package/Runtime/CesiumIonRasterOverlay.cs.meta +11 -0
- package/Runtime/CesiumIonServer.cs +137 -0
- package/Runtime/CesiumIonServer.cs.meta +11 -0
- package/Runtime/CesiumMetadata.cs +33 -0
- package/Runtime/CesiumMetadata.cs.meta +11 -0
- package/Runtime/CesiumMetadataValue.cs +1764 -0
- package/Runtime/CesiumMetadataValue.cs.meta +11 -0
- package/Runtime/CesiumMetadataValueType.cs +203 -0
- package/Runtime/CesiumMetadataValueType.cs.meta +11 -0
- package/Runtime/CesiumModelMetadata.cs +26 -0
- package/Runtime/CesiumModelMetadata.cs.meta +11 -0
- package/Runtime/CesiumObjectPool.cs +74 -0
- package/Runtime/CesiumObjectPool.cs.meta +11 -0
- package/Runtime/CesiumObjectPools.cs +39 -0
- package/Runtime/CesiumObjectPools.cs.meta +11 -0
- package/Runtime/CesiumOriginShift.cs +146 -0
- package/Runtime/CesiumOriginShift.cs.meta +11 -0
- package/Runtime/CesiumPointCloudRenderer.cs +246 -0
- package/Runtime/CesiumPointCloudRenderer.cs.meta +11 -0
- package/Runtime/CesiumPointCloudShading.cs +76 -0
- package/Runtime/CesiumPointCloudShading.cs.meta +11 -0
- package/Runtime/CesiumPolygonRasterOverlay.cs +109 -0
- package/Runtime/CesiumPolygonRasterOverlay.cs.meta +11 -0
- package/Runtime/CesiumPrimitiveFeatures.cs +130 -0
- package/Runtime/CesiumPrimitiveFeatures.cs.meta +11 -0
- package/Runtime/CesiumPropertyArray.cs +64 -0
- package/Runtime/CesiumPropertyArray.cs.meta +11 -0
- package/Runtime/CesiumPropertyTable.cs +126 -0
- package/Runtime/CesiumPropertyTable.cs.meta +11 -0
- package/Runtime/CesiumPropertyTableProperty.cs +1734 -0
- package/Runtime/CesiumPropertyTableProperty.cs.meta +11 -0
- package/Runtime/CesiumRasterOverlay.cs +239 -0
- package/Runtime/CesiumRasterOverlay.cs.meta +11 -0
- package/Runtime/CesiumRasterOverlayLoadFailureDetails.cs +65 -0
- package/Runtime/CesiumRasterOverlayLoadFailureDetails.cs.meta +11 -0
- package/Runtime/CesiumRuntime.asmdef +32 -0
- package/Runtime/CesiumRuntime.asmdef.meta +7 -0
- package/Runtime/CesiumRuntime.cs +3 -0
- package/Runtime/CesiumRuntime.cs.meta +11 -0
- package/Runtime/CesiumRuntimeSettings.cs +188 -0
- package/Runtime/CesiumRuntimeSettings.cs.meta +11 -0
- package/Runtime/CesiumSampleHeightResult.cs +47 -0
- package/Runtime/CesiumSampleHeightResult.cs.meta +11 -0
- package/Runtime/CesiumSimplePlanarEllipsoidCurve.cs +93 -0
- package/Runtime/CesiumSimplePlanarEllipsoidCurve.cs.meta +11 -0
- package/Runtime/CesiumSubScene.cs +473 -0
- package/Runtime/CesiumSubScene.cs.meta +11 -0
- package/Runtime/CesiumTileExcluder.cs +47 -0
- package/Runtime/CesiumTileExcluder.cs.meta +11 -0
- package/Runtime/CesiumTileMapServiceRasterOverlay.cs +93 -0
- package/Runtime/CesiumTileMapServiceRasterOverlay.cs.meta +11 -0
- package/Runtime/CesiumWebMapServiceRasterOverlay.cs +129 -0
- package/Runtime/CesiumWebMapServiceRasterOverlay.cs.meta +11 -0
- package/Runtime/CesiumWebMapTileServiceRasterOverlay.cs +414 -0
- package/Runtime/CesiumWebMapTileServiceRasterOverlay.cs.meta +3 -0
- package/Runtime/CesiumWgs84Ellipsoid.cs +75 -0
- package/Runtime/CesiumWgs84Ellipsoid.cs.meta +11 -0
- package/Runtime/ConfigureReinterop.cs +926 -0
- package/Runtime/ConfigureReinterop.cs.meta +11 -0
- package/Runtime/Helpers.cs +122 -0
- package/Runtime/Helpers.cs.meta +11 -0
- package/Runtime/ICesiumRestartable.cs +17 -0
- package/Runtime/ICesiumRestartable.cs.meta +11 -0
- package/Runtime/NativeCoroutine.cs +28 -0
- package/Runtime/NativeCoroutine.cs.meta +11 -0
- package/Runtime/NativeDownloadHandler.cs +29 -0
- package/Runtime/NativeDownloadHandler.cs.meta +11 -0
- package/Runtime/Resources/CesiumCreditSystem.prefab +78 -0
- package/Runtime/Resources/CesiumCreditSystem.prefab.meta +7 -0
- package/Runtime/Resources/CesiumCreditSystemRuntimeTheme.tss +2 -0
- package/Runtime/Resources/CesiumCreditSystemRuntimeTheme.tss.meta +11 -0
- package/Runtime/Resources/CesiumCreditSystemUI.uxml +4 -0
- package/Runtime/Resources/CesiumCreditSystemUI.uxml.meta +10 -0
- package/Runtime/Resources/CesiumCreditSystemUIPanelSettings.asset +38 -0
- package/Runtime/Resources/CesiumCreditSystemUIPanelSettings.asset.meta +8 -0
- package/Runtime/Resources/CesiumDefaultTilesetMaterial.mat +232 -0
- package/Runtime/Resources/CesiumDefaultTilesetMaterial.mat.meta +8 -0
- package/Runtime/Resources/CesiumDefaultTilesetShader.shadergraph +14271 -0
- package/Runtime/Resources/CesiumDefaultTilesetShader.shadergraph.meta +10 -0
- package/Runtime/Resources/CesiumPointCloudShading.hlsl +156 -0
- package/Runtime/Resources/CesiumPointCloudShading.hlsl.meta +7 -0
- package/Runtime/Resources/CesiumPointCloudShadingMaterial.mat +125 -0
- package/Runtime/Resources/CesiumPointCloudShadingMaterial.mat.meta +8 -0
- package/Runtime/Resources/CesiumPointCloudShadingShader.shader +73 -0
- package/Runtime/Resources/CesiumPointCloudShadingShader.shader.meta +10 -0
- package/Runtime/Resources/CesiumRasterOverlay.shadersubgraph +2207 -0
- package/Runtime/Resources/CesiumRasterOverlay.shadersubgraph.meta +10 -0
- package/Runtime/Resources/CesiumSelectTexCoords.shadersubgraph +722 -0
- package/Runtime/Resources/CesiumSelectTexCoords.shadersubgraph.meta +10 -0
- package/Runtime/Resources/CesiumUnlitTilesetMaterial.mat +261 -0
- package/Runtime/Resources/CesiumUnlitTilesetMaterial.mat.meta +8 -0
- package/Runtime/Resources/CesiumUnlitTilesetShader.shadergraph +5873 -0
- package/Runtime/Resources/CesiumUnlitTilesetShader.shadergraph.meta +10 -0
- package/Runtime/Resources/DynamicCamera.prefab +253 -0
- package/Runtime/Resources/DynamicCamera.prefab.meta +7 -0
- package/Runtime/Resources/TransformTextureCoordinates.shadersubgraph +2171 -0
- package/Runtime/Resources/TransformTextureCoordinates.shadersubgraph.meta +10 -0
- package/Runtime/Resources/green1x1.png +0 -0
- package/Runtime/Resources/green1x1.png.meta +123 -0
- package/Runtime/Resources.meta +8 -0
- package/Runtime/TestGltfModel.cs +56 -0
- package/Runtime/TestGltfModel.cs.meta +11 -0
- package/Runtime/TestReinterop.cs +21 -0
- package/Runtime/TestReinterop.cs.meta +11 -0
- package/Runtime/UnityLifetime.cs +27 -0
- package/Runtime/UnityLifetime.cs.meta +11 -0
- package/Runtime/WaitForTask.cs +25 -0
- package/Runtime/WaitForTask.cs.meta +11 -0
- package/Runtime/csc.rsp +1 -0
- package/Runtime/csc.rsp.meta +7 -0
- package/Runtime.meta +8 -0
- package/ThirdParty.json +27 -0
- package/ThirdParty.json.meta +7 -0
- package/WGS84.asset +18 -0
- package/WGS84.asset.meta +8 -0
- package/package.json +29 -0
- package/package.json.meta +7 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
using Reinterop;
|
|
2
|
+
using System;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using System.Collections.ObjectModel;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
|
|
7
|
+
namespace CesiumForUnity
|
|
8
|
+
{
|
|
9
|
+
/// <summary>
|
|
10
|
+
/// Manages the set of cameras that are used for Cesium3DTileset culling and level-of-detail.
|
|
11
|
+
/// </summary>
|
|
12
|
+
[DisallowMultipleComponent]
|
|
13
|
+
[AddComponentMenu("Cesium/Cesium Camera Manager")]
|
|
14
|
+
[Icon("Packages/com.cesium.unity/Editor/Resources/Cesium-24x24.png")]
|
|
15
|
+
public class CesiumCameraManager : MonoBehaviour
|
|
16
|
+
{
|
|
17
|
+
/// <summary>
|
|
18
|
+
/// Gets the instance suitable for use with the given game object.
|
|
19
|
+
/// </summary>
|
|
20
|
+
/// <remarks>
|
|
21
|
+
/// This method looks for an existing instance using `GetComponentInParent`. If it fails to find one, then
|
|
22
|
+
/// it will create one. When one is created, it be added to the same `GameObject` that has the
|
|
23
|
+
/// `CesiumGeoreference` (found using `GetComponentInParent` again) if there is one. If there is no
|
|
24
|
+
/// `CesiumGeoreference`, the instance is added to the originally-provided `GameObject`.
|
|
25
|
+
/// </remarks>
|
|
26
|
+
/// <param name="gameObject">The game object.</param>
|
|
27
|
+
/// <returns></returns>
|
|
28
|
+
public static CesiumCameraManager GetOrCreate(GameObject gameObject)
|
|
29
|
+
{
|
|
30
|
+
if (gameObject == null) throw new ArgumentNullException("gameObject");
|
|
31
|
+
|
|
32
|
+
CesiumCameraManager result = gameObject.GetComponentInParent<CesiumCameraManager>();
|
|
33
|
+
if (result == null)
|
|
34
|
+
return CesiumCameraManager.Create(gameObject);
|
|
35
|
+
else
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private static CesiumCameraManager Create(GameObject gameObject)
|
|
40
|
+
{
|
|
41
|
+
// Add it to the same game object that has the CesiumGeoreference, if any.
|
|
42
|
+
// Otherwise, add it to the current game object.
|
|
43
|
+
CesiumGeoreference georeference = gameObject.GetComponentInParent<CesiumGeoreference>();
|
|
44
|
+
GameObject owner = georeference == null ? gameObject : georeference.gameObject;
|
|
45
|
+
if (owner == null) return null;
|
|
46
|
+
|
|
47
|
+
return owner.AddComponent<CesiumCameraManager>();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
#region User-editable properties
|
|
51
|
+
|
|
52
|
+
[SerializeField]
|
|
53
|
+
private bool _useMainCamera = true;
|
|
54
|
+
|
|
55
|
+
/// <summary>
|
|
56
|
+
/// Determines whether the camera tagged `MainCamera` should be used for Cesium3DTileset
|
|
57
|
+
/// culling and level-of-detail.
|
|
58
|
+
/// </summary>
|
|
59
|
+
public bool useMainCamera
|
|
60
|
+
{
|
|
61
|
+
get => this._useMainCamera;
|
|
62
|
+
set
|
|
63
|
+
{
|
|
64
|
+
this._useMainCamera = value;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
[SerializeField]
|
|
69
|
+
private bool _useSceneViewCameraInEditor = true;
|
|
70
|
+
|
|
71
|
+
/// <summary>
|
|
72
|
+
/// Determines whether the camera associated with the Editor's active scene view should be
|
|
73
|
+
/// used for Cesium3DTileset culling and level-of-detail. In a game, this property has
|
|
74
|
+
/// no effect.
|
|
75
|
+
/// </summary>
|
|
76
|
+
public bool useSceneViewCameraInEditor
|
|
77
|
+
{
|
|
78
|
+
get => this._useSceneViewCameraInEditor;
|
|
79
|
+
set
|
|
80
|
+
{
|
|
81
|
+
this._useSceneViewCameraInEditor = value;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
[SerializeField]
|
|
86
|
+
private List<Camera> _additionalCameras = new List<Camera>();
|
|
87
|
+
|
|
88
|
+
/// <summary>
|
|
89
|
+
/// Other cameras to use for Cesium3DTileset culling and level-of-detail, in addition
|
|
90
|
+
/// to the ones controlled by <see cref="useMainCamera"/> and
|
|
91
|
+
/// <see cref="useSceneViewCameraInEditor"/>.
|
|
92
|
+
/// </summary>
|
|
93
|
+
/// <remarks>
|
|
94
|
+
/// These additional cameras will be used even when they are disabled, which is useful for
|
|
95
|
+
/// creating a virtual camera that affects Cesium3DTileset loading without being used
|
|
96
|
+
/// for rendering.
|
|
97
|
+
/// </remarks>
|
|
98
|
+
public List<Camera> additionalCameras
|
|
99
|
+
{
|
|
100
|
+
get => this._additionalCameras;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
#endregion
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
using System.Collections.Generic;
|
|
2
|
+
using Unity.Mathematics;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
#if SUPPORTS_SPLINES
|
|
6
|
+
using UnityEngine.Splines;
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
namespace CesiumForUnity
|
|
10
|
+
{
|
|
11
|
+
/// <summary>
|
|
12
|
+
/// A spline-based polygon used to rasterize 2D polygons on top of <see cref="Cesium3DTileset"/>s.
|
|
13
|
+
/// Cartographic polygons are only supported for Unity 2022.2 or later.
|
|
14
|
+
/// </summary>
|
|
15
|
+
[ExecuteInEditMode]
|
|
16
|
+
#if SUPPORTS_SPLINES
|
|
17
|
+
[RequireComponent(typeof(SplineContainer))]
|
|
18
|
+
[RequireComponent(typeof(CesiumGlobeAnchor))]
|
|
19
|
+
[AddComponentMenu("Cesium/Cesium Cartographic Polygon")]
|
|
20
|
+
#else
|
|
21
|
+
[AddComponentMenu("")]
|
|
22
|
+
#endif
|
|
23
|
+
[IconAttribute("Packages/com.cesium.unity/Editor/Resources/Cesium-24x24.png")]
|
|
24
|
+
public partial class CesiumCartographicPolygon : MonoBehaviour
|
|
25
|
+
{
|
|
26
|
+
#if SUPPORTS_SPLINES
|
|
27
|
+
private SplineContainer _splineContainer;
|
|
28
|
+
private CesiumGlobeAnchor _globeAnchor;
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
void OnEnable()
|
|
32
|
+
{
|
|
33
|
+
#if SUPPORTS_SPLINES
|
|
34
|
+
this._splineContainer = this.GetComponent<SplineContainer>();
|
|
35
|
+
this._globeAnchor = this.GetComponent<CesiumGlobeAnchor>();
|
|
36
|
+
|
|
37
|
+
// If this component is created before the Splines package is added, the
|
|
38
|
+
// "RequireComponent" attributes won't automatically apply. This extra check
|
|
39
|
+
// should ensure the required components exist.
|
|
40
|
+
if (this._splineContainer == null)
|
|
41
|
+
{
|
|
42
|
+
this._splineContainer = this.gameObject.AddComponent<SplineContainer>();
|
|
43
|
+
#if UNITY_EDITOR
|
|
44
|
+
this.Reset();
|
|
45
|
+
#endif
|
|
46
|
+
}
|
|
47
|
+
if (this._globeAnchor == null)
|
|
48
|
+
{
|
|
49
|
+
this._globeAnchor = this.gameObject.AddComponent<CesiumGlobeAnchor>();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
#elif UNITY_2022_2_OR_NEWER
|
|
53
|
+
Debug.LogError("CesiumCartographicPolygon requires the Splines package, which is currently not installed " +
|
|
54
|
+
"in the project. Install the Splines package using the Package Manager.");
|
|
55
|
+
#else
|
|
56
|
+
Debug.LogError("CesiumCartographicPolygon requires the Splines package, which is not available " +
|
|
57
|
+
"in this version of Unity.");
|
|
58
|
+
#endif
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
#if SUPPORTS_SPLINES && UNITY_EDITOR
|
|
62
|
+
void Reset()
|
|
63
|
+
{
|
|
64
|
+
IReadOnlyList<Spline> splines = this._splineContainer.Splines;
|
|
65
|
+
for (int i = splines.Count - 1; i >= 0; i--)
|
|
66
|
+
{
|
|
67
|
+
this._splineContainer.RemoveSpline(splines[i]);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
Spline defaultSpline = new Spline();
|
|
71
|
+
|
|
72
|
+
BezierKnot[] knots = new BezierKnot[] {
|
|
73
|
+
new BezierKnot(new float3(-100.0f, 0f, -100.0f)),
|
|
74
|
+
new BezierKnot(new float3(100.0f, 0f, -100.0f)),
|
|
75
|
+
new BezierKnot(new float3(100.0f, 0f, 100.0f)),
|
|
76
|
+
new BezierKnot(new float3(-100.0f, 0f, 100.0f)),
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
defaultSpline.Knots = knots;
|
|
80
|
+
defaultSpline.Closed = true;
|
|
81
|
+
defaultSpline.SetTangentMode(TangentMode.Linear);
|
|
82
|
+
|
|
83
|
+
this._splineContainer.AddSpline(defaultSpline);
|
|
84
|
+
}
|
|
85
|
+
#endif
|
|
86
|
+
|
|
87
|
+
static List<double2> emptyList = new List<double2>();
|
|
88
|
+
|
|
89
|
+
internal List<double2> GetCartographicPoints(Matrix4x4 worldToTileset)
|
|
90
|
+
{
|
|
91
|
+
#if SUPPORTS_SPLINES
|
|
92
|
+
CesiumGeoreference georeference = this._globeAnchor.GetComponentInParent<CesiumGeoreference>();
|
|
93
|
+
if (georeference == null)
|
|
94
|
+
{
|
|
95
|
+
return emptyList;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
IReadOnlyList<Spline> splines = this._splineContainer.Splines;
|
|
99
|
+
if (splines.Count == 0)
|
|
100
|
+
{
|
|
101
|
+
return emptyList;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (splines.Count > 1)
|
|
105
|
+
{
|
|
106
|
+
Debug.LogWarning("CesiumCartographicPolygon has multiple splines in its Spline component, " +
|
|
107
|
+
"but can only support one at a time. Only the first spline will be rasterized.");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
Spline spline = splines[0];
|
|
111
|
+
if (!spline.Closed)
|
|
112
|
+
{
|
|
113
|
+
Debug.LogError("Spline must be closed to be used as a cartographic polygon.");
|
|
114
|
+
return emptyList;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
BezierKnot[] knots = spline.ToArray();
|
|
118
|
+
List<double2> cartographicPoints = new List<double2>(knots.Length);
|
|
119
|
+
|
|
120
|
+
float4x4 localToWorld = this.transform.localToWorldMatrix;
|
|
121
|
+
|
|
122
|
+
for (int i = 0; i < knots.Length; i++)
|
|
123
|
+
{
|
|
124
|
+
if (spline.GetTangentMode(i) != TangentMode.Linear)
|
|
125
|
+
{
|
|
126
|
+
Debug.LogError("CesiumCartographicPolygon only supports linear splines.");
|
|
127
|
+
return emptyList;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
BezierKnot knot = knots[i];
|
|
131
|
+
|
|
132
|
+
// The spline points should be located in the tileset *exactly where they
|
|
133
|
+
// appear to be*. The way we do that is by getting their world position, and
|
|
134
|
+
// then transforming that world position to a Cesium3DTileset local position.
|
|
135
|
+
// That way if the tileset is transformed relative to the globe, the polygon
|
|
136
|
+
// will still affect the tileset where the user thinks it should.
|
|
137
|
+
|
|
138
|
+
float3 worldPosition = knot.Transform(localToWorld).Position;
|
|
139
|
+
float3 unityPosition = worldToTileset.MultiplyPoint3x4(worldPosition);
|
|
140
|
+
double3 ecefPosition = georeference.TransformUnityPositionToEarthCenteredEarthFixed(unityPosition);
|
|
141
|
+
double3 cartographicPosition = georeference.ellipsoid.CenteredFixedToLongitudeLatitudeHeight(ecefPosition);
|
|
142
|
+
|
|
143
|
+
cartographicPoints.Add(cartographicPosition.xy);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return cartographicPoints;
|
|
147
|
+
#else
|
|
148
|
+
return emptyList;
|
|
149
|
+
#endif
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
using Reinterop;
|
|
2
|
+
using System;
|
|
3
|
+
using System.Collections;
|
|
4
|
+
using System.Collections.Generic;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
using UnityEngine.SceneManagement;
|
|
7
|
+
using UnityEngine.Networking;
|
|
8
|
+
|
|
9
|
+
#if UNITY_EDITOR
|
|
10
|
+
using UnityEditor.SceneManagement;
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
namespace CesiumForUnity
|
|
14
|
+
{
|
|
15
|
+
/// <summary>
|
|
16
|
+
/// Represents an HTML element, either text or an image, that may also be hyperlinked.
|
|
17
|
+
/// This abstraction allows HTML parts of a credit to be converted to the desired UI elements
|
|
18
|
+
/// by a UI implementation.
|
|
19
|
+
/// </summary>
|
|
20
|
+
internal class CesiumCreditComponent
|
|
21
|
+
{
|
|
22
|
+
private string _text;
|
|
23
|
+
private string _link;
|
|
24
|
+
private int _imageId = -1;
|
|
25
|
+
|
|
26
|
+
/// <summary>
|
|
27
|
+
/// The text of this credit component. May be empty.
|
|
28
|
+
/// </summary>
|
|
29
|
+
public string text
|
|
30
|
+
{
|
|
31
|
+
get => this._text;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/// <summary>
|
|
35
|
+
/// The link used by this credit component. May be empty.
|
|
36
|
+
/// If the UI representation of this component is clicked, it should open this link.
|
|
37
|
+
/// </summary>
|
|
38
|
+
public string link
|
|
39
|
+
{
|
|
40
|
+
get => this._link;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/// <summary>
|
|
44
|
+
/// The ID of the image represented by this credit component.
|
|
45
|
+
/// </summary>
|
|
46
|
+
/// <remarks>
|
|
47
|
+
/// This ID corresponds to the index of the image in <see cref="CesiumCreditSystem.images"/>.
|
|
48
|
+
/// If it is -1, this component does not contain an image.
|
|
49
|
+
/// </remarks>
|
|
50
|
+
public int imageId
|
|
51
|
+
{
|
|
52
|
+
get => this._imageId;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public CesiumCreditComponent(string text, string link, int imageId)
|
|
56
|
+
{
|
|
57
|
+
this._text = text;
|
|
58
|
+
this._link = link;
|
|
59
|
+
this._imageId = imageId;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/// <summary>
|
|
64
|
+
/// Represents an HTML credit from a tileset or raster overlay. This abstracts an HTML string
|
|
65
|
+
/// into multiple <see cref="CesiumCreditComponent"/>s for UI rendering.
|
|
66
|
+
/// </summary>
|
|
67
|
+
internal class CesiumCredit
|
|
68
|
+
{
|
|
69
|
+
private List<CesiumCreditComponent> _components;
|
|
70
|
+
|
|
71
|
+
/// <summary>
|
|
72
|
+
/// The <see cref="CesiumCreditComponent"/>s that make up this credit.
|
|
73
|
+
/// </summary>
|
|
74
|
+
public List<CesiumCreditComponent> components
|
|
75
|
+
{
|
|
76
|
+
get => this._components;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public CesiumCredit() : this(new List<CesiumCreditComponent>())
|
|
80
|
+
{ }
|
|
81
|
+
|
|
82
|
+
public CesiumCredit(List<CesiumCreditComponent> components)
|
|
83
|
+
{
|
|
84
|
+
this._components = components;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/// <summary>
|
|
89
|
+
/// Manages credits / attribution for <see cref="Cesium3DTileset"/> and <see cref="CesiumRasterOverlay"/>.
|
|
90
|
+
/// </summary>
|
|
91
|
+
[ExecuteInEditMode]
|
|
92
|
+
[ReinteropNativeImplementation("CesiumForUnityNative::CesiumCreditSystemImpl", "CesiumCreditSystemImpl.h")]
|
|
93
|
+
[AddComponentMenu("Cesium/Cesium Credit System")]
|
|
94
|
+
[IconAttribute("Packages/com.cesium.unity/Editor/Resources/Cesium-24x24.png")]
|
|
95
|
+
public partial class CesiumCreditSystem : MonoBehaviour
|
|
96
|
+
{
|
|
97
|
+
private static CesiumCreditSystem _defaultCreditSystem;
|
|
98
|
+
|
|
99
|
+
private List<CesiumCredit> _onScreenCredits;
|
|
100
|
+
private List<CesiumCredit> _popupCredits;
|
|
101
|
+
private List<Texture2D> _images;
|
|
102
|
+
private int _numLoadingImages = 0;
|
|
103
|
+
|
|
104
|
+
const string base64Prefix = "data:image/png;base64,";
|
|
105
|
+
const string defaultName = "CesiumCreditSystemDefault";
|
|
106
|
+
const string creditSystemPrefabName = "CesiumCreditSystem";
|
|
107
|
+
|
|
108
|
+
#region Fields and Events
|
|
109
|
+
/// <summary>
|
|
110
|
+
/// The current on-screen credits, represented as <see cref="CesiumCredit"/>s.
|
|
111
|
+
/// </summary>
|
|
112
|
+
internal List<CesiumCredit> onScreenCredits
|
|
113
|
+
{
|
|
114
|
+
get => this._onScreenCredits;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/// <summary>
|
|
118
|
+
/// The credits to be displayed in the "Data Attribution" panel,
|
|
119
|
+
/// represented as <see cref="CesiumCredit"/>s.
|
|
120
|
+
/// </summary>
|
|
121
|
+
internal List<CesiumCredit> popupCredits
|
|
122
|
+
{
|
|
123
|
+
get => this._popupCredits;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/// <summary>
|
|
127
|
+
/// The images loaded by this credit system.
|
|
128
|
+
/// </summary>
|
|
129
|
+
internal List<Texture2D> images
|
|
130
|
+
{
|
|
131
|
+
get => this._images;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/// <summary>
|
|
135
|
+
/// Encapsulates a method that receives the on-screen and popup credits in <see cref="CesiumCredit"/>
|
|
136
|
+
/// form. This can be used to create UI components for the credits after they have been updated.
|
|
137
|
+
/// </summary>
|
|
138
|
+
/// <param name="onScreenCredits">The on-screen credits.</param>
|
|
139
|
+
/// <param name="onPopupCredits">The popup credits.</param>
|
|
140
|
+
internal delegate void CreditsUpdateDelegate(List<CesiumCredit> onScreenCredits, List<CesiumCredit> onPopupCredits);
|
|
141
|
+
|
|
142
|
+
/// <summary>
|
|
143
|
+
/// An event that is raised when credits have been updated by the credit system. This is
|
|
144
|
+
/// only raised when the credits in view have actually changed.
|
|
145
|
+
/// </summary>
|
|
146
|
+
/// <remarks>
|
|
147
|
+
/// If the credit system is loading any images for its credits, the update will not be broadcasted
|
|
148
|
+
/// until all image loads are complete.
|
|
149
|
+
/// </remarks>
|
|
150
|
+
internal event CreditsUpdateDelegate OnCreditsUpdate;
|
|
151
|
+
#endregion
|
|
152
|
+
|
|
153
|
+
#region Unity Messages
|
|
154
|
+
|
|
155
|
+
private void OnEnable()
|
|
156
|
+
{
|
|
157
|
+
this._onScreenCredits = new List<CesiumCredit>();
|
|
158
|
+
this._popupCredits = new List<CesiumCredit>();
|
|
159
|
+
this._images = new List<Texture2D>();
|
|
160
|
+
|
|
161
|
+
Cesium3DTileset.OnSetShowCreditsOnScreen += this.ForceUpdateCredits;
|
|
162
|
+
#if UNITY_EDITOR
|
|
163
|
+
EditorSceneManager.sceneClosing += HandleClosingSceneView;
|
|
164
|
+
#endif
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
private void Update()
|
|
168
|
+
{
|
|
169
|
+
this.UpdateCredits(false);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
private void OnDestroy()
|
|
173
|
+
{
|
|
174
|
+
Cesium3DTileset.OnSetShowCreditsOnScreen -= this.ForceUpdateCredits;
|
|
175
|
+
|
|
176
|
+
for (int i = 0, count = this._images.Count; i < count; i++)
|
|
177
|
+
{
|
|
178
|
+
if (this._images != null)
|
|
179
|
+
{
|
|
180
|
+
UnityLifetime.Destroy(this._images[i]);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
this._images.Clear();
|
|
185
|
+
|
|
186
|
+
if (_defaultCreditSystem == this)
|
|
187
|
+
{
|
|
188
|
+
_defaultCreditSystem = null;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/// <summary>
|
|
193
|
+
/// This handles the destruction of the credit system whenever the application is quit
|
|
194
|
+
/// from a built executable or from play mode.
|
|
195
|
+
/// </summary>
|
|
196
|
+
private void OnApplicationQuit()
|
|
197
|
+
{
|
|
198
|
+
UnityLifetime.Destroy(this.gameObject);
|
|
199
|
+
}
|
|
200
|
+
#endregion
|
|
201
|
+
|
|
202
|
+
/// <summary>
|
|
203
|
+
/// Forces the credits to update, bypassing any performance optimizations in play.
|
|
204
|
+
/// This ensures the credit system accounts for changes to the credits, e.g. if
|
|
205
|
+
/// <see cref="Cesium3DTileset.showCreditsOnScreen"/> is changed on a tileset.</param>
|
|
206
|
+
/// </summary>
|
|
207
|
+
private void ForceUpdateCredits()
|
|
208
|
+
{
|
|
209
|
+
this.UpdateCredits(true);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/// <summary>
|
|
213
|
+
/// Updates the underlying native credit system.
|
|
214
|
+
/// </summary>
|
|
215
|
+
/// <param name="forceUpdate">Whether to force the credit system to update.</param>
|
|
216
|
+
private partial void UpdateCredits(bool forceUpdate);
|
|
217
|
+
|
|
218
|
+
internal void BroadcastCreditsUpdate()
|
|
219
|
+
{
|
|
220
|
+
if (this.OnCreditsUpdate != null)
|
|
221
|
+
{
|
|
222
|
+
this.OnCreditsUpdate(this._onScreenCredits, this._popupCredits);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/// <summary>
|
|
227
|
+
/// Creates an instance of the default credit system prefab.
|
|
228
|
+
/// </summary>
|
|
229
|
+
/// <remarks>
|
|
230
|
+
/// This prefab comes with a <see cref="CesiumCreditSystemUI"/> component so that
|
|
231
|
+
/// the credits UI is automatically added to the editor and scene. However,
|
|
232
|
+
/// the CesiumCreditSystem class is uncoupled from any UI implementation itself.
|
|
233
|
+
/// </remarks>
|
|
234
|
+
/// <returns>The new CesiumCreditSystem instance.</returns>
|
|
235
|
+
private static CesiumCreditSystem CreateDefaultCreditSystem()
|
|
236
|
+
{
|
|
237
|
+
GameObject creditSystemPrefab = Resources.Load<GameObject>(creditSystemPrefabName);
|
|
238
|
+
GameObject creditSystemGameObject = UnityEngine.Object.Instantiate(creditSystemPrefab);
|
|
239
|
+
creditSystemGameObject.name = defaultName;
|
|
240
|
+
creditSystemGameObject.hideFlags = HideFlags.HideAndDontSave;
|
|
241
|
+
|
|
242
|
+
return creditSystemGameObject.GetComponent<CesiumCreditSystem>();
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/// <summary>
|
|
246
|
+
/// Gets the default credit system, or creates a new default credit system instance if none exist.
|
|
247
|
+
/// </summary>
|
|
248
|
+
/// <returns>The default CesiumCreditSystem instance.</returns>
|
|
249
|
+
internal static CesiumCreditSystem GetDefaultCreditSystem()
|
|
250
|
+
{
|
|
251
|
+
if (_defaultCreditSystem == null)
|
|
252
|
+
{
|
|
253
|
+
CesiumCreditSystem[] creditSystems = Resources.FindObjectsOfTypeAll<CesiumCreditSystem>();
|
|
254
|
+
for (int i = 0; i < creditSystems.Length; i++)
|
|
255
|
+
{
|
|
256
|
+
if (creditSystems[i].gameObject.name == defaultName)
|
|
257
|
+
{
|
|
258
|
+
_defaultCreditSystem = creditSystems[i];
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (_defaultCreditSystem == null)
|
|
265
|
+
{
|
|
266
|
+
_defaultCreditSystem = CreateDefaultCreditSystem();
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return _defaultCreditSystem;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
internal bool HasLoadingImages()
|
|
273
|
+
{
|
|
274
|
+
return this._numLoadingImages > 0;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
internal IEnumerator LoadImage(string url)
|
|
278
|
+
{
|
|
279
|
+
int index = this._images.Count;
|
|
280
|
+
|
|
281
|
+
// Initialize a texture of arbitrary size as a placeholder,
|
|
282
|
+
// so that when other images are loaded, their IDs align properly
|
|
283
|
+
// with the current list of images.
|
|
284
|
+
Texture2D texture = new Texture2D(1, 1);
|
|
285
|
+
this._images.Add(texture);
|
|
286
|
+
|
|
287
|
+
if (url.LastIndexOf(base64Prefix, base64Prefix.Length) == 0)
|
|
288
|
+
{
|
|
289
|
+
// Load an image from a string that contains the
|
|
290
|
+
// "data:image/png;base64," prefix
|
|
291
|
+
string byteString = url.Substring(base64Prefix.Length);
|
|
292
|
+
byte[] bytes = Convert.FromBase64String(byteString);
|
|
293
|
+
if (!texture.LoadImage(bytes))
|
|
294
|
+
{
|
|
295
|
+
Debug.Log("Could not parse image from base64 string.");
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
else
|
|
299
|
+
{
|
|
300
|
+
// Load an image from a URL.
|
|
301
|
+
UnityWebRequest request = UnityWebRequestTexture.GetTexture(url);
|
|
302
|
+
this._numLoadingImages++;
|
|
303
|
+
yield return request.SendWebRequest();
|
|
304
|
+
|
|
305
|
+
if (request.result == UnityWebRequest.Result.ConnectionError ||
|
|
306
|
+
request.result == UnityWebRequest.Result.ProtocolError)
|
|
307
|
+
{
|
|
308
|
+
Debug.Log(request.error);
|
|
309
|
+
}
|
|
310
|
+
else
|
|
311
|
+
{
|
|
312
|
+
texture = ((DownloadHandlerTexture)request.downloadHandler).texture;
|
|
313
|
+
|
|
314
|
+
Texture2D placeholderTexture = this._images[index];
|
|
315
|
+
this._images[index] = texture;
|
|
316
|
+
UnityLifetime.Destroy(placeholderTexture);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
this._numLoadingImages--;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
texture.wrapMode = TextureWrapMode.Clamp;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
#if UNITY_EDITOR
|
|
327
|
+
/// <summary>
|
|
328
|
+
/// This handles the destruction of the credit system between scene switches in the Unity Editor.
|
|
329
|
+
/// Without this, the credit system will live between instances and won't properly render the
|
|
330
|
+
/// current scene's credits.
|
|
331
|
+
/// </summary>
|
|
332
|
+
/// <param name="scene">The scene.</param>
|
|
333
|
+
/// <param name="removingScene">Whether or not the closing scene is also being removed.</param>
|
|
334
|
+
private static void HandleClosingSceneView(Scene scene, bool removingScene)
|
|
335
|
+
{
|
|
336
|
+
if (_defaultCreditSystem != null && _defaultCreditSystem.gameObject.scene == scene)
|
|
337
|
+
{
|
|
338
|
+
UnityLifetime.Destroy(_defaultCreditSystem.gameObject);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
#endif
|
|
342
|
+
}
|
|
343
|
+
}
|