Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by laurencenairne · Feb 03, 2017 at 01:25 PM · scripting problemvr

Trying to use the Gear VR touchpad as a play/pause input

Hi,

I've been trying for a while now with little luck to set up a pause/play in my project. The idea is that I have a texture playing a 360 video (this bit works fine). I have a Media Player Ctrl script that handles playback and playback states (paused, playing, etc).

I then wish to use a second script to handle the input functions using a tap on the Gear VR's touchpad - which I am to understand counts as a 'mouse 0' type input. I've checked Fire1 uses mouse 0 as the positive button.

I'm not getting any errors on my script in Unity, but tapping the touchpad isn't affecting playback at all :(

I'm a bit out of my depth with C# right now as a newbie, but I've used the basis of another GUI script and I believe it's connecting correctly with the media player Ctrl script.

Any thoughts or suggestions?

Thanks in advance, Laurence

 using UnityEngine;
 using System.Collections;
 using System;
 
 namespace VRStandardAssets.Utils
 {
     public class MedaiPlayerSampleGUI : MonoBehaviour
     {
 
 
         public MediaPlayerCtrl scrMedia;
         public VRInteractiveItem m_VRInteractiveItem;
 
         public bool m_bFinish = false;
         
         // Use this for initialization
         void Start()
         {
             scrMedia.OnEnd += OnEnd;
 
         }
 
 
         // Update is called once per frame
         void Update()
         {
             if (scrMedia.GetCurrentState() == MediaPlayerCtrl.MEDIAPLAYER_STATE.PLAYING)
             {
                 if (Input.GetButtonDown("Fire1"))
                 {
                     scrMedia.Pause();
                 }
             }
             if (scrMedia.GetCurrentState() == MediaPlayerCtrl.MEDIAPLAYER_STATE.PAUSED)
             {
                 if (Input.GetButtonDown("Fire1"))
                 {
                     scrMedia.Play();
                 }
             }
         }
         void OnEnd()
         {
             m_bFinish = true;
         }
     }
 }
Comment
Add comment · Show 1
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 laurencenairne · Feb 06, 2017 at 05:33 PM 0
Share

So I believe I've managed to solve the problem of getting the Gear VR touchpad to update the Pause/Play status on the Video$$anonymous$$anager now. If it's of any interest to anyone, my solution was as follows:

 using UnityEngine;
 using VRStandardAssets.Utils;
 
 namespace VRStandardAssets.Examples
 {
     // This script shows a simple example of how
     // swipe controls can be handled.
     public class VideoPausePlay : $$anonymous$$onoBehaviour
     {
         [SerializeField] private $$anonymous$$ediaPlayerCtrl scr$$anonymous$$edia;
         private VRInput m_VRInput;
         public VRInput OnClick;
 
         void Update()
         {
             if (OnClick != null)
                 HandleOnClick();
         }
         
         //Handle the OnClick events deter$$anonymous$$ed by current state of playback in Video$$anonymous$$anager
         void HandleOnClick()
         {
             if (scr$$anonymous$$edia.GetCurrentState() == $$anonymous$$ediaPlayerCtrl.$$anonymous$$EDIAPLAYER_STAT$$anonymous$$PLAYING)
                 scr$$anonymous$$edia.Pause();
 
             else if (scr$$anonymous$$edia.GetCurrentState() == $$anonymous$$ediaPlayerCtrl.$$anonymous$$EDIAPLAYER_STAT$$anonymous$$PAUSED)
                 scr$$anonymous$$edia.Play();
         }
     }
 }

The trouble I have now is that the state is changing without any input at all :/ It's progress of sorts I guess. I'll update if I crack it any time soon, but in the mean time, please do let me know if I'm making some glaringly obvious bumble!

1 Reply

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

Answer by laurencenairne · Feb 07, 2017 at 02:14 PM

By Jove, I've got it!

The trick is not to bother using VRInput for this, just use the regular Input.GetMouseButtonDown method.

Touchpad counts as mouse 0, so if the script is written like so:

 using UnityEngine;
 using VRStandardAssets.Utils;
 
 namespace VRStandardAssets.Examples
 {
     public class VideoPausePlay : MonoBehaviour
     {
         [SerializeField] private MediaPlayerCtrl scrMedia;
 
         void Update()
         {
             if (Input.GetMouseButtonDown(0))
                 if (scrMedia.GetCurrentState() == MediaPlayerCtrl.MEDIAPLAYER_STATE.PLAYING)
                     scrMedia.Pause();
 
                 else if (scrMedia.GetCurrentState() == MediaPlayerCtrl.MEDIAPLAYER_STATE.PAUSED)
                     scrMedia.Play();
         }
     }
 }

This will Pause when the video is playing, or Play when the video is paused. In the Editor you will need to drag the gameObject that contains the MediaPlayerCtrl script onto the corresponding "Scr Media" field so it knows which Video Manager to look to for player status.

Comment
Add comment · 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

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

129 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity 5 remote not working thogether with Cardboard VR 2 Answers

When I toggle off the GvrViewer the Y mouse sensivity camera look is locked 0 Answers

OVR Walking Animation trigger. 0 Answers

Switch between 5 cameras in the game by clicking. 0 Answers

How to send event to my canvas via script 0 Answers


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