Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by HugoZandel · Sep 10, 2014 at 08:46 PM · androidandroidpluginandroid-manifest

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;
                 }
             });

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image VesuvianPrime · Sep 10, 2014 at 10:04 PM 1
Share

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.

avatar image Fanttum · Sep 10, 2014 at 11:19 PM 0
Share

Not sure how this works with touch by might as well try out reset input axis.

avatar image HugoZandel · Sep 11, 2014 at 02:34 PM 0
Share

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.

avatar image TheDDestroyer12 · Sep 14, 2014 at 07:19 PM 0
Share

It'd be easier to help you if you could post your code.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

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!

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image HugoZandel · Sep 11, 2014 at 04:59 PM 0
Share

Yes your code would work however I'm looking for a way to do this in java inside my plugin.

avatar image TheDDestroyer12 · Sep 14, 2014 at 06:39 PM 0
Share
 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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges