Skip to content

Commit

Permalink
Merge pull request #449 from CesiumGS/ion-single-user
Browse files Browse the repository at this point in the history
Support in Unity for Cesium ion servers running in single-user authentication mode.
  • Loading branch information
kring authored May 1, 2024
2 parents fdecc86 + 10717d9 commit 7ca9c5a
Show file tree
Hide file tree
Showing 13 changed files with 268 additions and 90 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ jobs:
cd ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity
dotnet run --project Build~
ls -l ~/cesium/CesiumForUnityBuildProject
- name: Print log
if: ${{ failure() }}
run: |
cat /Users/runner/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-iOS/build.log
- name: Publish package artifact
if: ${{ success() }}
uses: actions/upload-artifact@v4
Expand Down
6 changes: 5 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change Log

### ? - ?
### v1.10.0 - 2024-05-01

##### Additions :tada:

- Added support for Cesium ion servers in single user mode. Tokens are not required to stream assets from such servers.

##### Fixes :wrench:

Expand Down
17 changes: 17 additions & 0 deletions Editor/CesiumEditorUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ static void
return;
}

if(details.tileset.ionServer == null)
{
return;
}

CesiumIonSession session = CesiumIonServerManager.instance.GetSession(details.tileset.ionServer);
if(session == null)
{
return;
}

if(!session.IsAuthenticationRequired())
{
// The server we're connected to doesn't use tokens, so reauthorizing would be pointless
return;
}

// Check for a 401 connecting to Cesium ion, which means the token is invalid
// (or perhaps the asset ID is). Also check for a 404, because ion returns 404
// when the token is valid but not authorized for the asset.
Expand Down
8 changes: 7 additions & 1 deletion Editor/CesiumEditorWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ private void OnDisable()
private bool _isIonConnecting = false;
private bool _isIonProfileLoaded = false;
private bool _isIonLoadingProfile = false;
private bool _isAuthenticationRequired = true;
private CesiumIonServerSelector _serverSelector;

private Vector2 _scrollPosition = Vector2.zero;
Expand All @@ -67,6 +68,7 @@ void OnGUI()
this._isIonConnecting = ion.IsConnecting();
this._isIonProfileLoaded = ion.IsProfileLoaded();
this._isIonLoadingProfile = ion.IsLoadingProfile();
this._isAuthenticationRequired = ion.IsAuthenticationRequired();
}

GUILayout.Space(5);
Expand Down Expand Up @@ -146,12 +148,16 @@ void DrawCesiumToolbar()
"Upload a tileset to Cesium ion to process it for efficient streaming to Cesium for Unity",
true,
this.UploadToIon);

EditorGUI.BeginDisabledGroup(!this._isAuthenticationRequired);
this.DrawToolbarButton(
"Token",
ToolbarButton.Token,
"Select or create a token to use to access Cesium ion assets",
this._isAuthenticationRequired ? "Select or create a token to use to access Cesium ion assets" : "Tokens are disabled for Cesium ion servers running in single-user mode.",
false,
this.SetToken);
EditorGUI.EndDisabledGroup();

this.DrawToolbarButton(
"Learn",
ToolbarButton.Learn,
Expand Down
1 change: 1 addition & 0 deletions Editor/CesiumIonSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public CesiumIonSession(CesiumIonServer server)

public partial bool IsDefaultsLoaded();
public partial bool IsLoadingDefaults();
public partial bool IsAuthenticationRequired();

public partial void Connect();
public partial void Resume();
Expand Down
16 changes: 14 additions & 2 deletions native~/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ if (EDITOR)
add_subdirectory(Editor)
endif()

set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR})

# Specify all targets that need to compile bitcode
if (${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
set (ALL_TARGETS
Expand All @@ -76,6 +78,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
CesiumGltfReader
CesiumJsonReader
CesiumRasterOverlays
CesiumQuantizedMeshTerrain
CesiumUtility
draco_attributes
draco_compression_attributes_dec
Expand All @@ -94,7 +97,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
expected-lite
GSL
httplib
ktx_read
ktx
meshoptimizer
modp_b64
spdlog
Expand All @@ -112,10 +115,19 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
)
set(MESHOPT_BUILD_SHARED_LIBS OFF BOOL FORCE)
install(TARGETS tidy-static)
install(TARGETS ${ALL_TARGETS} PUBLIC_HEADER EXCLUDE_FROM_ALL)
install(
TARGETS ${ALL_TARGETS}
PUBLIC_HEADER
EXCLUDE_FROM_ALL
FRAMEWORK
DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
set_target_properties(cesium-native-tests PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1)
set_target_properties(tidy-static PROPERTIES EXCLUDE_FROM_ALL 0 EXCLUDE_FROM_DEFAULT_BUILD 0)
set_target_properties(${ALL_TARGETS} PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE "YES")

# ktx tags itself as a FRAMEWORK on iOS, which causes linker errors. Undo that.
set_target_properties(ktx PROPERTIES FRAMEWORK FALSE)
endif()


Loading

0 comments on commit 7ca9c5a

Please sign in to comment.