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,581 @@
|
|
|
1
|
+
using UnityEditor;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
using UnityEditor.Build;
|
|
4
|
+
using UnityEditor.Build.Reporting;
|
|
5
|
+
using System.Diagnostics;
|
|
6
|
+
using System.Runtime.CompilerServices;
|
|
7
|
+
using System.IO;
|
|
8
|
+
using System.Text;
|
|
9
|
+
using System;
|
|
10
|
+
using System.Collections.Generic;
|
|
11
|
+
#if UNITY_ANDROID
|
|
12
|
+
using UnityEditor.Android;
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
namespace CesiumForUnity
|
|
16
|
+
{
|
|
17
|
+
internal struct PlatformToBuild
|
|
18
|
+
{
|
|
19
|
+
public BuildTargetGroup platformGroup;
|
|
20
|
+
public BuildTarget platform;
|
|
21
|
+
public bool isDevelopment;
|
|
22
|
+
public bool isCleanBuild;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
internal enum LibraryCpuArchitecture
|
|
26
|
+
{
|
|
27
|
+
x86_64,
|
|
28
|
+
ARM64
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/// <summary>
|
|
32
|
+
/// When the user builds a Player (built game) in the Unity Editor, this class manages
|
|
33
|
+
/// automatically compiling a suitable version of the native C++ CesiumForUnityNative
|
|
34
|
+
/// shared library to go with it.
|
|
35
|
+
/// </summary>
|
|
36
|
+
internal class CompileCesiumForUnityNative :
|
|
37
|
+
AssetPostprocessor,
|
|
38
|
+
IPreprocessBuildWithReport,
|
|
39
|
+
IPostBuildPlayerScriptDLLs
|
|
40
|
+
{
|
|
41
|
+
internal class LibraryToBuild
|
|
42
|
+
{
|
|
43
|
+
public BuildTarget Platform = BuildTarget.StandaloneWindows64;
|
|
44
|
+
public BuildTargetGroup PlatformGroup = BuildTargetGroup.Standalone;
|
|
45
|
+
public LibraryCpuArchitecture? Cpu = null;
|
|
46
|
+
public string SourceDirectory = "";
|
|
47
|
+
public string BuildDirectory = "build";
|
|
48
|
+
public string GeneratedDirectoryName = "generated-Unknown";
|
|
49
|
+
public string Configuration = "RelWithDebInfo";
|
|
50
|
+
public string InstallDirectory = "";
|
|
51
|
+
public bool CleanBuild = false;
|
|
52
|
+
public string Toolchain;
|
|
53
|
+
public List<string> ExtraConfigureArgs = new List<string>();
|
|
54
|
+
public List<string> ExtraBuildArgs = new List<string>();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// This field is static because OnPreprocessBuild and OnPreprocessAsset are called on different
|
|
58
|
+
// instances of this class.
|
|
59
|
+
private static Dictionary<string, LibraryToBuild> importsInProgress = new Dictionary<string, LibraryToBuild>();
|
|
60
|
+
|
|
61
|
+
/// <summary>
|
|
62
|
+
/// At the start of the build, create placeholders for the CesiumForUnityNative shared
|
|
63
|
+
/// libraries that will be produced during the build.
|
|
64
|
+
/// </summary>
|
|
65
|
+
/// <remarks>
|
|
66
|
+
/// <para>
|
|
67
|
+
/// This is necessary because, if a shared library is not present at the start of the build,
|
|
68
|
+
/// Unity won't pick it up if it is created during the build. However, as long as it exists,
|
|
69
|
+
/// Unity will pick up the latest version.
|
|
70
|
+
/// </para>
|
|
71
|
+
/// <para>
|
|
72
|
+
/// The shared library assets are imported synchronously, and Unity will call
|
|
73
|
+
/// `OnPreprocessAsset` at the start of the import in order to allow us to set
|
|
74
|
+
/// the import settings.
|
|
75
|
+
/// </para>
|
|
76
|
+
/// </remarks>
|
|
77
|
+
/// <param name="report"></param>
|
|
78
|
+
public void OnPreprocessBuild(BuildReport report)
|
|
79
|
+
{
|
|
80
|
+
importsInProgress.Clear();
|
|
81
|
+
|
|
82
|
+
AssetDatabase.StartAssetEditing();
|
|
83
|
+
try
|
|
84
|
+
{
|
|
85
|
+
LibraryToBuild[] libraries = GetLibrariesToBuildForPlatform(report.summary, finalLibrariesOnly: true);
|
|
86
|
+
foreach (LibraryToBuild library in libraries)
|
|
87
|
+
{
|
|
88
|
+
CreatePlaceholders(library, "CesiumForUnityNative-Runtime");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
finally
|
|
92
|
+
{
|
|
93
|
+
AssetDatabase.StopAssetEditing();
|
|
94
|
+
importsInProgress.Clear();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
internal static void CreatePlaceholders(LibraryToBuild libraryToBuild, string sharedLibraryName)
|
|
99
|
+
{
|
|
100
|
+
Directory.CreateDirectory(libraryToBuild.InstallDirectory);
|
|
101
|
+
|
|
102
|
+
string libraryFilename = GetSharedLibraryFilename(sharedLibraryName, libraryToBuild.Platform);
|
|
103
|
+
string libraryPath = Path.Combine(libraryToBuild.InstallDirectory, libraryFilename);
|
|
104
|
+
if (!File.Exists(libraryPath))
|
|
105
|
+
File.WriteAllText(libraryPath, "This is not a real shared library, it is a placeholder.", Encoding.UTF8);
|
|
106
|
+
|
|
107
|
+
string projectPath = Path.GetFullPath(Path.Combine(Application.dataPath, ".."));
|
|
108
|
+
string importPath = Path.GetRelativePath(projectPath, libraryPath).Replace("\\", "/");
|
|
109
|
+
importsInProgress.Add(importPath, libraryToBuild);
|
|
110
|
+
AssetDatabase.ImportAsset(importPath, ImportAssetOptions.ForceSynchronousImport);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
private static string GetSharedLibraryFilename(string baseName, BuildTarget target)
|
|
114
|
+
{
|
|
115
|
+
switch (target)
|
|
116
|
+
{
|
|
117
|
+
case BuildTarget.StandaloneWindows:
|
|
118
|
+
case BuildTarget.StandaloneWindows64:
|
|
119
|
+
case BuildTarget.WSAPlayer:
|
|
120
|
+
return $"{baseName}.dll";
|
|
121
|
+
case BuildTarget.iOS:
|
|
122
|
+
return $"lib{baseName}.a";
|
|
123
|
+
case BuildTarget.StandaloneOSX:
|
|
124
|
+
return $"lib{baseName}.dylib";
|
|
125
|
+
default:
|
|
126
|
+
// Assume Linux-ish
|
|
127
|
+
return $"lib{baseName}.so";
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/// <summary>
|
|
132
|
+
/// This Unity message is invoked at the start of the asset imports initiated in OnPreprocessBuild
|
|
133
|
+
/// above and allows us to configure how the placeholder shared libraries are imported.
|
|
134
|
+
/// </summary>
|
|
135
|
+
private void OnPreprocessAsset()
|
|
136
|
+
{
|
|
137
|
+
LibraryToBuild libraryToBuild;
|
|
138
|
+
if (!importsInProgress.TryGetValue(assetPath, out libraryToBuild))
|
|
139
|
+
return;
|
|
140
|
+
|
|
141
|
+
PluginImporter importer = this.assetImporter as PluginImporter;
|
|
142
|
+
if (importer == null)
|
|
143
|
+
return;
|
|
144
|
+
|
|
145
|
+
CompileCesiumForUnityNative.ConfigurePlugin(libraryToBuild, importer);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
private static void ConfigurePlugin(LibraryToBuild library, PluginImporter importer)
|
|
149
|
+
{
|
|
150
|
+
importer.SetCompatibleWithAnyPlatform(false);
|
|
151
|
+
importer.SetCompatibleWithEditor(false);
|
|
152
|
+
importer.SetCompatibleWithPlatform(library.Platform, true);
|
|
153
|
+
|
|
154
|
+
if (library.Platform == BuildTarget.Android ||
|
|
155
|
+
library.Platform == BuildTarget.StandaloneOSX)
|
|
156
|
+
{
|
|
157
|
+
if(library.Cpu != null)
|
|
158
|
+
importer.SetPlatformData(library.Platform, "CPU", library.Cpu.ToString());
|
|
159
|
+
}
|
|
160
|
+
else if (library.Platform == BuildTarget.WSAPlayer)
|
|
161
|
+
{
|
|
162
|
+
string wsaPlatform = null;
|
|
163
|
+
if (library.Cpu == LibraryCpuArchitecture.ARM64)
|
|
164
|
+
wsaPlatform = "ARM64";
|
|
165
|
+
else if (library.Cpu == LibraryCpuArchitecture.x86_64)
|
|
166
|
+
wsaPlatform = "X64";
|
|
167
|
+
else
|
|
168
|
+
UnityEngine.Debug.LogAssertion("Unsupported processor: " + library.Cpu);
|
|
169
|
+
importer.SetPlatformData(library.Platform, "CPU", wsaPlatform);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
private static void OnPostprocessAllAssets(
|
|
174
|
+
string[] importedAssets,
|
|
175
|
+
string[] deletedAssets,
|
|
176
|
+
string[] movedAssets,
|
|
177
|
+
string[] movedFromAssetPaths,
|
|
178
|
+
bool didDomainReload)
|
|
179
|
+
{
|
|
180
|
+
// On macOS, the settings in OnPreprocessAsset above seem to be ignored.
|
|
181
|
+
// So reapply here as well.
|
|
182
|
+
foreach (string imported in importedAssets)
|
|
183
|
+
{
|
|
184
|
+
LibraryToBuild libraryToBuild;
|
|
185
|
+
if (!importsInProgress.TryGetValue(imported, out libraryToBuild))
|
|
186
|
+
continue;
|
|
187
|
+
|
|
188
|
+
PluginImporter importer = AssetImporter.GetAtPath(imported) as PluginImporter;
|
|
189
|
+
if (importer == null)
|
|
190
|
+
continue;
|
|
191
|
+
|
|
192
|
+
CompileCesiumForUnityNative.ConfigurePlugin(libraryToBuild, importer);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
public int callbackOrder => 0;
|
|
197
|
+
|
|
198
|
+
/// <summary>
|
|
199
|
+
/// True if Unity should exit immediately after `OnPostBuildPlayerScriptDLLs` completes.
|
|
200
|
+
/// </summary>
|
|
201
|
+
public static bool ExitAfterCompile = false;
|
|
202
|
+
|
|
203
|
+
/// <summary>
|
|
204
|
+
/// The exit code of the last step of the build process, such as cmake or lipo.
|
|
205
|
+
/// </summary>
|
|
206
|
+
private static int LastRunExitCode = 0;
|
|
207
|
+
|
|
208
|
+
/// <summary>
|
|
209
|
+
/// Invoked after the managed script assemblies are compiled, including the CesiumForUnity
|
|
210
|
+
/// managed code. Building the CesiumForUnity assembly will generate C++ code via Reinterop,
|
|
211
|
+
/// so we implement this method in order to compile that generated C++ code to a shared library
|
|
212
|
+
/// and inject it into the in-progress Player build.
|
|
213
|
+
/// </summary>
|
|
214
|
+
/// <param name="report"></param>
|
|
215
|
+
public void OnPostBuildPlayerScriptDLLs(BuildReport report)
|
|
216
|
+
{
|
|
217
|
+
LibraryToBuild[] libraries = GetLibrariesToBuildForPlatform(report.summary, finalLibrariesOnly: false);
|
|
218
|
+
foreach (LibraryToBuild library in libraries)
|
|
219
|
+
{
|
|
220
|
+
BuildNativeLibrary(library);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (report.summary.platform == BuildTarget.StandaloneOSX)
|
|
224
|
+
{
|
|
225
|
+
// On macOS, build for both ARM64 and x64, and then use the lipo tool to combine
|
|
226
|
+
// the libraries for the two CPUs into a single library.
|
|
227
|
+
List<string> args = new List<string>();
|
|
228
|
+
args.Add("-create");
|
|
229
|
+
foreach (LibraryToBuild library in libraries)
|
|
230
|
+
{
|
|
231
|
+
args.Add(Path.Combine(library.InstallDirectory, "libCesiumForUnityNative-Runtime.dylib"));
|
|
232
|
+
}
|
|
233
|
+
args.Add("-output");
|
|
234
|
+
args.Add(Path.GetFullPath(Path.Combine(libraries[0].InstallDirectory, "..", "libCesiumForUnityNative-Runtime.dylib")));
|
|
235
|
+
Process p = Process.Start("lipo", string.Join(' ', args));
|
|
236
|
+
p.WaitForExit();
|
|
237
|
+
if (p.ExitCode != 0)
|
|
238
|
+
{
|
|
239
|
+
UnityEngine.Debug.LogError($"Invocation of 'lipo' tool failed. The command-line was:{Environment.NewLine}lipo {string.Join(' ', args)}");
|
|
240
|
+
LastRunExitCode = p.ExitCode;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
foreach (LibraryToBuild library in libraries)
|
|
244
|
+
{
|
|
245
|
+
Directory.Delete(library.InstallDirectory, true);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (ExitAfterCompile)
|
|
250
|
+
{
|
|
251
|
+
EditorApplication.Exit(LastRunExitCode);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/// <summary>
|
|
256
|
+
///
|
|
257
|
+
/// </summary>
|
|
258
|
+
/// <param name="summary"></param>
|
|
259
|
+
/// <param name="finalLibrariesOnly">
|
|
260
|
+
/// True if only the final libraries shipped to end users should be included, not any intermediate libraries created along the way.
|
|
261
|
+
/// This affects the macOS libraries, where two libraries are built (for x64 and ARM64), but then they are compiled into a
|
|
262
|
+
/// single library supporting both platforms.
|
|
263
|
+
/// </param>
|
|
264
|
+
/// <returns></returns>
|
|
265
|
+
private static LibraryToBuild[] GetLibrariesToBuildForPlatform(BuildSummary summary, bool finalLibrariesOnly)
|
|
266
|
+
{
|
|
267
|
+
List<LibraryToBuild> result = new List<LibraryToBuild>();
|
|
268
|
+
|
|
269
|
+
if (summary.platform == BuildTarget.StandaloneOSX)
|
|
270
|
+
{
|
|
271
|
+
if (finalLibrariesOnly)
|
|
272
|
+
{
|
|
273
|
+
result.Add(GetLibraryToBuild(summary));
|
|
274
|
+
}
|
|
275
|
+
else
|
|
276
|
+
{
|
|
277
|
+
result.Add(GetLibraryToBuild(summary, LibraryCpuArchitecture.x86_64));
|
|
278
|
+
result.Add(GetLibraryToBuild(summary, LibraryCpuArchitecture.ARM64));
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
else if (summary.platform == BuildTarget.Android)
|
|
282
|
+
{
|
|
283
|
+
// We support ARM64 and x86_64. If any other architectures are enabled, log a warning.
|
|
284
|
+
AndroidArchitecture supported = AndroidArchitecture.ARM64 | AndroidArchitecture.X86_64;
|
|
285
|
+
if ((PlayerSettings.Android.targetArchitectures & ~supported) != 0)
|
|
286
|
+
UnityEngine.Debug.LogWarning("Cesium for Unity only supports the ARM64 and x86_64 CPU architectures on Android. Other architectures will not work.");
|
|
287
|
+
|
|
288
|
+
if (PlayerSettings.Android.targetArchitectures.HasFlag(AndroidArchitecture.ARM64))
|
|
289
|
+
result.Add(GetLibraryToBuild(summary, LibraryCpuArchitecture.ARM64));
|
|
290
|
+
if (PlayerSettings.Android.targetArchitectures.HasFlag(AndroidArchitecture.X86_64))
|
|
291
|
+
result.Add(GetLibraryToBuild(summary, LibraryCpuArchitecture.x86_64));
|
|
292
|
+
}
|
|
293
|
+
else if (summary.platform == BuildTarget.WSAPlayer)
|
|
294
|
+
{
|
|
295
|
+
result.Add(GetLibraryToBuild(summary, LibraryCpuArchitecture.x86_64));
|
|
296
|
+
result.Add(GetLibraryToBuild(summary, LibraryCpuArchitecture.ARM64));
|
|
297
|
+
}
|
|
298
|
+
else
|
|
299
|
+
{
|
|
300
|
+
result.Add(GetLibraryToBuild(summary));
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
return result.ToArray();
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
public static LibraryToBuild GetLibraryToBuild(BuildSummary summary, LibraryCpuArchitecture? cpu = null)
|
|
307
|
+
{
|
|
308
|
+
return GetLibraryToBuild(new PlatformToBuild()
|
|
309
|
+
{
|
|
310
|
+
platform = summary.platform,
|
|
311
|
+
platformGroup = summary.platformGroup,
|
|
312
|
+
isDevelopment = summary.options.HasFlag(BuildOptions.Development),
|
|
313
|
+
isCleanBuild = summary.options.HasFlag(BuildOptions.CleanBuildCache)
|
|
314
|
+
}, cpu);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
public static LibraryToBuild GetLibraryToBuild(PlatformToBuild platform, LibraryCpuArchitecture? cpu = null)
|
|
318
|
+
{
|
|
319
|
+
string sourceFilename = GetSourceFilePathName();
|
|
320
|
+
string packagePath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(sourceFilename), $".."));
|
|
321
|
+
string nativeDirectory = Path.Combine(packagePath, "native~");
|
|
322
|
+
|
|
323
|
+
string platformDirectoryName = GetDirectoryNameForPlatform(platform);
|
|
324
|
+
|
|
325
|
+
LibraryToBuild library = new LibraryToBuild();
|
|
326
|
+
library.Platform = platform.platform;
|
|
327
|
+
library.PlatformGroup = platform.platformGroup;
|
|
328
|
+
library.Cpu = cpu;
|
|
329
|
+
library.SourceDirectory = nativeDirectory;
|
|
330
|
+
library.BuildDirectory = Path.Combine(nativeDirectory, $"build-{platformDirectoryName}");
|
|
331
|
+
library.GeneratedDirectoryName = $"generated-{platformDirectoryName}";
|
|
332
|
+
library.Configuration = platform.isDevelopment
|
|
333
|
+
? "Debug"
|
|
334
|
+
: "RelWithDebInfo";
|
|
335
|
+
library.InstallDirectory = GetInstallDirectoryForPlatform(platform, packagePath);
|
|
336
|
+
library.CleanBuild = platform.isCleanBuild;
|
|
337
|
+
|
|
338
|
+
if (IsEditor(platform))
|
|
339
|
+
library.ExtraConfigureArgs.Add("-DEDITOR=on");
|
|
340
|
+
|
|
341
|
+
if (platform.platformGroup == BuildTargetGroup.Android)
|
|
342
|
+
{
|
|
343
|
+
library.Toolchain = $"extern/android-toolchain.cmake";
|
|
344
|
+
if (cpu == null)
|
|
345
|
+
cpu = LibraryCpuArchitecture.ARM64;
|
|
346
|
+
if (cpu == LibraryCpuArchitecture.x86_64)
|
|
347
|
+
library.ExtraConfigureArgs.Add("-DCMAKE_ANDROID_ARCH_ABI=x86_64");
|
|
348
|
+
else
|
|
349
|
+
library.ExtraConfigureArgs.Add("-DCMAKE_ANDROID_ARCH_ABI=arm64-v8a");
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
if (platform.platformGroup == BuildTargetGroup.iOS)
|
|
353
|
+
{
|
|
354
|
+
library.Toolchain = "extern/ios-toolchain.cmake";
|
|
355
|
+
library.ExtraConfigureArgs.Add("-GXcode");
|
|
356
|
+
library.ExtraConfigureArgs.Add("-DCMAKE_SYSTEM_NAME=iOS");
|
|
357
|
+
library.ExtraConfigureArgs.Add("-DCMAKE_SYSTEM_PROCESSOR=aarch64");
|
|
358
|
+
library.ExtraConfigureArgs.Add("-DCMAKE_OSX_ARCHITECTURES=arm64");
|
|
359
|
+
library.ExtraConfigureArgs.Add("-DOSX_DEPLOYMENT_TARGET=12");
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
if (platform.platform == BuildTarget.StandaloneOSX)
|
|
363
|
+
{
|
|
364
|
+
if (cpu != null)
|
|
365
|
+
library.ExtraConfigureArgs.Add("-DCMAKE_OSX_ARCHITECTURES=" + cpu.ToString().ToLowerInvariant());
|
|
366
|
+
|
|
367
|
+
library.ExtraConfigureArgs.Add("-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15");
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
if (platform.platform == BuildTarget.WSAPlayer)
|
|
371
|
+
{
|
|
372
|
+
library.ExtraConfigureArgs.Add("-DCMAKE_SYSTEM_NAME=WindowsStore");
|
|
373
|
+
library.ExtraConfigureArgs.Add("-DCMAKE_SYSTEM_VERSION=10.0");
|
|
374
|
+
switch (cpu)
|
|
375
|
+
{
|
|
376
|
+
case LibraryCpuArchitecture.x86_64:
|
|
377
|
+
library.ExtraConfigureArgs.Add("-DCMAKE_SYSTEM_PROCESSOR=AMD64");
|
|
378
|
+
library.ExtraConfigureArgs.Add("-DCMAKE_GENERATOR_PLATFORM=x64");
|
|
379
|
+
break;
|
|
380
|
+
case LibraryCpuArchitecture.ARM64:
|
|
381
|
+
library.ExtraConfigureArgs.Add("-DCMAKE_SYSTEM_PROCESSOR=ARM64");
|
|
382
|
+
library.ExtraConfigureArgs.Add("-DCMAKE_GENERATOR_PLATFORM=ARM64");
|
|
383
|
+
break;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
if (cpu != null)
|
|
388
|
+
{
|
|
389
|
+
library.InstallDirectory = Path.Combine(library.InstallDirectory, cpu.ToString().ToLowerInvariant());
|
|
390
|
+
library.BuildDirectory += "-" + cpu.ToString().ToLowerInvariant();
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
return library;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
private static bool IsEditor(PlatformToBuild platform)
|
|
397
|
+
{
|
|
398
|
+
return IsEditor(platform.platformGroup, platform.platform);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
private static bool IsEditor(BuildTargetGroup platformGroup, BuildTarget platform)
|
|
402
|
+
{
|
|
403
|
+
return platformGroup == BuildTargetGroup.Unknown && platform == BuildTarget.NoTarget;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
private static bool IsIOS(BuildTargetGroup platformGroup, BuildTarget platform)
|
|
407
|
+
{
|
|
408
|
+
return platformGroup == BuildTargetGroup.iOS && platform == BuildTarget.iOS;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
private static string GetDirectoryNameForPlatform(PlatformToBuild platform)
|
|
412
|
+
{
|
|
413
|
+
return GetDirectoryNameForPlatform(platform.platformGroup, platform.platform);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
private static string GetDirectoryNameForPlatform(BuildTargetGroup platformGroup, BuildTarget platform)
|
|
417
|
+
{
|
|
418
|
+
if (IsEditor(platformGroup, platform))
|
|
419
|
+
return "Editor";
|
|
420
|
+
else if (IsIOS(platformGroup, platform))
|
|
421
|
+
return "iOS";
|
|
422
|
+
// Make sure we use "WSA" and not "Metro"
|
|
423
|
+
else if (platformGroup == BuildTargetGroup.WSA)
|
|
424
|
+
return "WSA";
|
|
425
|
+
return platformGroup.ToString();
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
private static string GetInstallDirectoryForPlatform(PlatformToBuild platform, string packagePath)
|
|
429
|
+
{
|
|
430
|
+
if (IsEditor(platform))
|
|
431
|
+
return Path.Combine(packagePath, "Editor");
|
|
432
|
+
return Path.Combine(packagePath, "Plugins", GetDirectoryNameForPlatform(platform));
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
internal static void BuildNativeLibrary(LibraryToBuild library)
|
|
436
|
+
{
|
|
437
|
+
if (library.CleanBuild && library.BuildDirectory.Length > 2 && Directory.Exists(library.BuildDirectory))
|
|
438
|
+
Directory.Delete(library.BuildDirectory, true);
|
|
439
|
+
Directory.CreateDirectory(library.BuildDirectory);
|
|
440
|
+
|
|
441
|
+
try
|
|
442
|
+
{
|
|
443
|
+
string logFilename = Path.Combine(library.BuildDirectory, "build.log");
|
|
444
|
+
string projectPath = Path.Combine(Application.dataPath, "..");
|
|
445
|
+
string logDisplayName = Path.GetRelativePath(projectPath, logFilename);
|
|
446
|
+
|
|
447
|
+
EditorUtility.DisplayProgressBar($"Building CesiumForUnityNative: {Path.GetFileName(library.BuildDirectory)}", $"See {logDisplayName}.", 0.0f);
|
|
448
|
+
|
|
449
|
+
using (StreamWriter log = new StreamWriter(logFilename, false, Encoding.UTF8))
|
|
450
|
+
{
|
|
451
|
+
ProcessStartInfo startInfo = new ProcessStartInfo();
|
|
452
|
+
startInfo.UseShellExecute = false;
|
|
453
|
+
if (library.Platform == BuildTarget.StandaloneOSX || library.Platform == BuildTarget.iOS)
|
|
454
|
+
{
|
|
455
|
+
startInfo.FileName = File.Exists("/Applications/CMake.app/Contents/bin/cmake") ? "/Applications/CMake.app/Contents/bin/cmake" : "cmake";
|
|
456
|
+
}
|
|
457
|
+
else
|
|
458
|
+
{
|
|
459
|
+
startInfo.FileName = "cmake";
|
|
460
|
+
}
|
|
461
|
+
startInfo.CreateNoWindow = true;
|
|
462
|
+
startInfo.WorkingDirectory = library.SourceDirectory;
|
|
463
|
+
startInfo.RedirectStandardError = true;
|
|
464
|
+
startInfo.RedirectStandardOutput = true;
|
|
465
|
+
ConfigureEnvironmentVariables(startInfo.Environment, library);
|
|
466
|
+
|
|
467
|
+
List<string> args = new List<string>()
|
|
468
|
+
{
|
|
469
|
+
"-B",
|
|
470
|
+
library.BuildDirectory,
|
|
471
|
+
"-S",
|
|
472
|
+
library.SourceDirectory,
|
|
473
|
+
"-DEDITOR=false",
|
|
474
|
+
$"-DCMAKE_BUILD_TYPE={library.Configuration}",
|
|
475
|
+
$"-DCMAKE_INSTALL_PREFIX=\"{library.InstallDirectory}\"",
|
|
476
|
+
$"-DREINTEROP_GENERATED_DIRECTORY={library.GeneratedDirectoryName}",
|
|
477
|
+
};
|
|
478
|
+
args.AddRange(library.ExtraConfigureArgs);
|
|
479
|
+
|
|
480
|
+
if (library.Toolchain != null)
|
|
481
|
+
args.Add($"-DCMAKE_TOOLCHAIN_FILE=\"{library.Toolchain}\"");
|
|
482
|
+
|
|
483
|
+
startInfo.Arguments = string.Join(' ', args);
|
|
484
|
+
|
|
485
|
+
RunAndLog(startInfo, log, logFilename);
|
|
486
|
+
|
|
487
|
+
args = new List<string>()
|
|
488
|
+
{
|
|
489
|
+
"--build",
|
|
490
|
+
$"\"{library.BuildDirectory}\"",
|
|
491
|
+
"--config",
|
|
492
|
+
library.Configuration,
|
|
493
|
+
"--parallel",
|
|
494
|
+
(Environment.ProcessorCount + 1).ToString(),
|
|
495
|
+
"--target",
|
|
496
|
+
"install"
|
|
497
|
+
};
|
|
498
|
+
args.AddRange(library.ExtraBuildArgs);
|
|
499
|
+
startInfo.Arguments = string.Join(' ', args);
|
|
500
|
+
RunAndLog(startInfo, log, logFilename);
|
|
501
|
+
|
|
502
|
+
if (library.Platform == BuildTarget.iOS)
|
|
503
|
+
AssetDatabase.Refresh();
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
finally
|
|
507
|
+
{
|
|
508
|
+
EditorUtility.ClearProgressBar();
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
private static void RunAndLog(ProcessStartInfo startInfo, StreamWriter log, string logFilename)
|
|
513
|
+
{
|
|
514
|
+
using (Process configure = new Process())
|
|
515
|
+
{
|
|
516
|
+
configure.OutputDataReceived += (sender, e) =>
|
|
517
|
+
{
|
|
518
|
+
log.WriteLine(e.Data);
|
|
519
|
+
log.Flush();
|
|
520
|
+
};
|
|
521
|
+
configure.ErrorDataReceived += (sender, e) =>
|
|
522
|
+
{
|
|
523
|
+
log.WriteLine(e.Data);
|
|
524
|
+
log.Flush();
|
|
525
|
+
};
|
|
526
|
+
configure.StartInfo = startInfo;
|
|
527
|
+
configure.Start();
|
|
528
|
+
configure.BeginOutputReadLine();
|
|
529
|
+
configure.BeginErrorReadLine();
|
|
530
|
+
configure.WaitForExit();
|
|
531
|
+
|
|
532
|
+
if (configure.ExitCode != 0)
|
|
533
|
+
{
|
|
534
|
+
UnityEngine.Debug.LogError($"An error occurred while building CesiumForUnityNative. See {logFilename} for details. The command-line was:{Environment.NewLine}{startInfo.FileName} {startInfo.Arguments}");
|
|
535
|
+
LastRunExitCode = configure.ExitCode;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
private static void ConfigureEnvironmentVariables(IDictionary<string, string> environment, LibraryToBuild library)
|
|
541
|
+
{
|
|
542
|
+
// CMake can't deal with back slashes (Windows) in the ANDROID_NDK_ROOT environment variable.
|
|
543
|
+
// So replace them with forward slashes.
|
|
544
|
+
string ndkRoot = environment.ContainsKey("ANDROID_NDK_ROOT") ? environment["ANDROID_NDK_ROOT"] : null;
|
|
545
|
+
#if UNITY_ANDROID
|
|
546
|
+
if (ndkRoot == null)
|
|
547
|
+
{
|
|
548
|
+
// We're building for Android but don't have a known NDK root. Try asking Unity for it.
|
|
549
|
+
ndkRoot = AndroidExternalToolsSettings.ndkRootPath;
|
|
550
|
+
}
|
|
551
|
+
#endif
|
|
552
|
+
|
|
553
|
+
// On Windows, use the make program included in the NDK. Because Visual Studio (which is usually
|
|
554
|
+
// the default) won't work to build for Android.
|
|
555
|
+
if (library.Platform == BuildTarget.Android && Environment.OSVersion.Platform == PlatformID.Win32NT)
|
|
556
|
+
{
|
|
557
|
+
library.ExtraConfigureArgs.Add("-G Ninja");
|
|
558
|
+
|
|
559
|
+
// If the NDK root has a space in it, this will confuse broken software like OpenSSL's build process.
|
|
560
|
+
// So map a drive letter and rewrite the path.
|
|
561
|
+
if (ndkRoot != null && ndkRoot.Contains(' '))
|
|
562
|
+
{
|
|
563
|
+
if (!Directory.Exists("N:\\"))
|
|
564
|
+
{
|
|
565
|
+
Process.Start("subst", "N: \"" + ndkRoot + "\"").WaitForExit();
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
ndkRoot = "N:\\";
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
if (!string.IsNullOrEmpty(ndkRoot))
|
|
573
|
+
environment["ANDROID_NDK_ROOT"] = ndkRoot.Replace('\\', '/');
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
private static string GetSourceFilePathName([CallerFilePath] string callerFilePath = null)
|
|
577
|
+
{
|
|
578
|
+
return callerFilePath == null ? "" : callerFilePath;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|