Enable long press, pan and scale gestures for the Godot Android Editor

Fix the bug causing the editor to crash when running the project.
This commit is contained in:
Fredia Huya-Kouadio 2022-09-05 21:24:58 -07:00
parent 1b3511ad49
commit c3c0bea615
4 changed files with 23 additions and 1 deletions

View file

@ -207,7 +207,9 @@ bool ProgressDialog::task_step(const String &p_task, const String &p_state, int
DisplayServer::get_singleton()->process_events(); DisplayServer::get_singleton()->process_events();
} }
#ifndef ANDROID_ENABLED
Main::iteration(); // this will not work on a lot of platforms, so it's only meant for the editor Main::iteration(); // this will not work on a lot of platforms, so it's only meant for the editor
#endif
return cancelled; return cancelled;
} }

View file

@ -77,6 +77,12 @@ open class GodotEditor : FullScreenGodotApp() {
} }
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
// Enable long press, panning and scaling gestures
godotFragment?.renderView?.inputHandler?.apply {
enableLongPress(enableLongPressGestures())
enablePanningAndScalingGestures(enablePanAndScaleGestures())
}
} }
private fun updateCommandLineParams(args: Array<String>?) { private fun updateCommandLineParams(args: Array<String>?) {
@ -148,6 +154,16 @@ open class GodotEditor : FullScreenGodotApp() {
*/ */
protected open fun overrideOrientationRequest() = true protected open fun overrideOrientationRequest() = true
/**
* Enable long press gestures for the Godot Android editor.
*/
protected open fun enableLongPressGestures() = true
/**
* Enable pan and scale gestures for the Godot Android editor.
*/
protected open fun enablePanAndScaleGestures() = true
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data) super.onActivityResult(requestCode, resultCode, data)
// Check if we got the MANAGE_EXTERNAL_STORAGE permission // Check if we got the MANAGE_EXTERNAL_STORAGE permission

View file

@ -35,4 +35,8 @@ package org.godotengine.editor
*/ */
class GodotGame : GodotEditor() { class GodotGame : GodotEditor() {
override fun overrideOrientationRequest() = false override fun overrideOrientationRequest() = false
override fun enableLongPressGestures() = false
override fun enablePanAndScaleGestures() = false
} }

View file

@ -1023,7 +1023,7 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
} }
@Keep @Keep
private GodotRenderView getRenderView() { // used by native side to get renderView public GodotRenderView getRenderView() { // used by native side to get renderView
return mRenderView; return mRenderView;
} }