Godot Engine – Multi-platform 2D and 3D game engine
Minor polish and fixes for the Android XR editor
Fredia Huya-Kouadio8a62cde72ff4
diff --git a/platform/android/java/editor/build.gradle b/platform/android/java/editor/build.gradleindex 269df35358b..3c5b3f52a6e 100644--- a/platform/android/java/editor/build.gradle+++ b/platform/android/java/editor/build.gradle@@ -223,7 +223,7 @@ dependencies {// Android XR dependenciesandroidImplementation "org.godotengine:godot-openxr-vendors-androidxr:$versions.openxrVendorsVersion"- androidImplementation "androidx.xr.scenecore:scenecore:1.0.0-beta02"+ androidImplementation "androidx.xr.scenecore:scenecore:1.0.0-rc01"// Meta dependencieshorizonosImplementation "org.godotengine:godot-openxr-vendors-meta:$versions.openxrVendorsVersion"diff --git a/platform/android/java/editor/src/android/AndroidManifest.xml b/platform/android/java/editor/src/android/AndroidManifest.xmlindex 5f77c58ca3a..975aaf851a5 100644--- a/platform/android/java/editor/src/android/AndroidManifest.xml+++ b/platform/android/java/editor/src/android/AndroidManifest.xml@@ -20,6 +20,8 @@<uses-permission android:name="android.permission.HEAD_TRACKING" /><application>+ <meta-data android:name="com.google.ar.core" android:value="optional" />+<uses-native-library android:name="libopenxr.google.so" android:required="false" /><propertydiff --git a/platform/android/java/editor/src/android/java/org/godotengine/editor/GodotEditor.kt b/platform/android/java/editor/src/android/java/org/godotengine/editor/GodotEditor.ktindex 351c1ac7588..93d16866cae 100644--- a/platform/android/java/editor/src/android/java/org/godotengine/editor/GodotEditor.kt+++ b/platform/android/java/editor/src/android/java/org/godotengine/editor/GodotEditor.kt@@ -37,12 +37,16 @@ import android.os.Handlerimport android.util.Logimport androidx.xr.runtime.Sessionimport androidx.xr.runtime.SessionCreateSuccess+import androidx.xr.runtime.math.FloatSize3dimport androidx.xr.runtime.math.IntSize2dimport androidx.xr.runtime.math.Poseimport androidx.xr.runtime.math.Quaternionimport androidx.xr.runtime.math.Vector3import androidx.xr.scenecore.ActivityPanelEntityimport androidx.xr.scenecore.MovableComponent+import androidx.xr.scenecore.PanelEntity+import androidx.xr.scenecore.ResizableComponent+import androidx.xr.scenecore.ResizeEventimport androidx.xr.scenecore.SpatialCapabilityimport androidx.xr.scenecore.sceneimport java.util.LinkedList@@ -57,6 +61,9 @@ open class GodotEditor : BaseGodotEditor() {companion object {private val TAG = GodotEditor::class.java.simpleName++ private val MAIN_WINDOW_PANEL_MIN_SIZE = FloatSize3d(0.45f, 0.25f, 0.0f)+ private val SPATIAL_CONTAINER_PANEL_MIN_SIZE = FloatSize3d(0.05f, 0.05f, 0.0f)}private val handler = Handler()@@ -86,6 +93,7 @@ open class GodotEditor : BaseGodotEditor() {result.session.scene.apply{addSpatialCapabilitiesChangedListener(spatialCapabilitiesChangedListener)mainPanelEntity.addComponent(MovableComponent.createSystemMovable(result.session))+ mainPanelEntity.addComponent(ResizableComponent.create(result.session, MAIN_WINDOW_PANEL_MIN_SIZE) { resizePanelEntity(it) })}return@lazy result.session} else {@@ -134,6 +142,13 @@ open class GodotEditor : BaseGodotEditor() {return false}+ private fun resizePanelEntity(resizeEvent: ResizeEvent) {+ if (resizeEvent.entity is PanelEntity && resizeEvent.resizeState == ResizeEvent.ResizeState.END) {+ Log.v(TAG, "Resizing panel entity ${resizeEvent.entity} to ${resizeEvent.newSize}")+ (resizeEvent.entity as PanelEntity).size = resizeEvent.newSize.to2d()+ }+ }+private fun startSpatialContainerActivity(newInstance: Intent) {if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {val scene = session!!.scene@@ -146,6 +161,9 @@ open class GodotEditor : BaseGodotEditor() {scene.activitySpace)activityPanel.addComponent(MovableComponent.createSystemMovable(session!!))+ val spatialContainerPanelResizeComponent = ResizableComponent.create(session!!, SPATIAL_CONTAINER_PANEL_MIN_SIZE) { resizePanelEntity(it) }+ spatialContainerPanelResizeComponent.isFixedAspectRatioEnabled = true+ activityPanel.addComponent(spatialContainerPanelResizeComponent)// We remove the 'NEW_TASK' flag as launching in a new task prevents embedding.newInstance.removeFlags(Intent.FLAG_ACTIVITY_NEW_TASK)