- Home /
Is it possible to block unity's input?
Hello,
I have a custom Android plugin to play video over unity. It's all working great.
However, I need to block unity's input because there's a scene running behind the video.
I've tried overriding the onTouchEvent on my Activity to no avail.
My Activity is extending UnityPlayerActivity
@Override
public boolean onTouchEvent(MotionEvent event) {
// return true should consume event
return true;
}
Also, I tried adding a custom view on up of my video player with fill_parent and used onTouchEvent.
Unity is always getting inputs. Is this possible?
Thanks,
Hugo
EDIT #1 : I've tried setting onTouchListeners everywhere and it's still not working. I'm not able to stop the propagation.
unityPlayer is found searching for if (view instanceof UnityPlayer)
unityPlayer.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// return true should consume the event...
return true;
}
});
I think your best bet is going to be to write your own input wrapper. That way you can implement your own input disabling functionality.
Not sure how this works with touch by might as well try out reset input axis.
I'm trying to achieve this in my java android plugin. The iOS version is already blocking events so I don't want to add unnecessary complexity to my unity code.
It'd be easier to help you if you could post your code.
Answer by TheDDestroyer12 · Sep 11, 2014 at 02:47 PM
Just don't check for input then. I'm usualy doing it like this in all my controller scripts (C#) :
using UnityEngine;
using System.Collections;
class myclass
{
// This is what controlls if the player will be able to move
boolean isControllable = false;
void Update()
{
if(isControllable)
{
// This will be ran if the player IS able to move
}
else
{
// This will be ran if the player IS NOT able to move
}
}
}
By setting "isControllable" to false at the beginning of movie, the player won't move during the movie! Just set it to true again when the movie is finished, and the player will be able to move again!
/TheDDestroyer12
EDIT: I think I missunderstood you, but I think this will work anyway. You just have to put it in your controller script in the unity project, and change the "isControllable" variable from the android plugin (don't know if that's possible, but I think so).
Good luck!
Yes your code would work however I'm looking for a way to do this in java inside my plugin.
Time.timeScale = 0;
You may be able to access that from outside of unity. If that works, it will simply pause the game. Just set it back to 1 when you want to play again!
/TheDDestroyer12
Your answer
![](https://koobas.hobune.stream/wayback/20220613162740im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How do I use the Android Library in Unity? 0 Answers
correct approach for using e.g. three android plugins 0 Answers
Android build crashes on start up. 2 Answers
Get Phone number of android mobile device - Android native code to Unity c# 3 Answers
CommandInvokationFailure: Gradle build failed. unity 2019.4.22 1 Answer