Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[RELEASED] TVOS Easy Input Helper- Solves input on Apple TV (Siri Remote and mFi controllers)

Discussion in 'Assets and Asset Store' started by greggtwep16, Dec 18, 2015.

  1. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    Easy Input Helper makes supporting input for the new Apple TV a breeze. Whether you want support for the Siri remote or mFi controllers, everything that is unique about the platform is accessible in one easy to use API. Saves a lot of time over having to code everything yourself.

    Asset Store Link: https://www.assetstore.unity3d.com/en/#!/content/49843

    Cost: $35





    Check out our online documentation.


    Features
    • Full siri remote support
    • Full mFi controller support
    • Standard controls for common things so no coding required
    • Nice high level API (quick click, long click, double click, touch, accelerometer etc.)
    • Emulates input in editor so no more wasting time doing a build on every change
    • Accelerometer/gyro support
    • Touch and controller input module for Unity GUI support with no coding required
    • 6 example scenes
    • Easy callbacks to use if you want to do something custom
     
  2. CoCoNutti

    CoCoNutti

    Joined:
    Nov 30, 2009
    Posts:
    513
    Hi, I'm looking to get this but before I do, have a question.
    I need the touch pad to act like a mouse - i.e. controls a pointer/reticule that when held over a game object on the scene, I can click on that object and it will do it's thing (e.g. move it). I can't see in your examples how I could achieve this?
    Thanks
     
  3. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    This is easily done, you would simply attach the touchpad controller like you see on red sphere in the controls example in the video. Instead of attaching it to the sphere, you would just attach it to the pointer in your game (whether you have it look like a mouse pointer, semi-transparent sphere, or whatever else you already have for your game.

    The touchpad would then move the pointer around, and you would simply raycast off of the pointer's current position if you were wanting to click and select or otherwise interact with other items.

    Hope that helps. Certainly let me know if you have any other questions.
     
  4. CoCoNutti

    CoCoNutti

    Joined:
    Nov 30, 2009
    Posts:
    513
    Thanks will give that a shot.
    While I have you, do you know anything about saving game info on tvOS? Can't find any documentation. I usually use Easy Save 2, but running the build, it doesn't appear to work. Can I only use PlayerPrefs for tvOS?
     
  5. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    I'm not the author of Easy Save but Apple is severely limiting local storage on the Apple TV. I believe I had used that asset in the past and it actually saves to files which isn't allowed on the Apple TV (but is allowed on other platforms). Unity playerprefs is also severely limited on the Apple TV to 500kb (half a megabyte). If your settings/game saves etc. fits in that space then you can use it, if not you will need to keep your saves in the cloud (cloudkit, icloud, or other 3rd party cloud services).
     
  6. CoCoNutti

    CoCoNutti

    Joined:
    Nov 30, 2009
    Posts:
    513
    Ok. My saves are very small so should be ok, but will look into Cloud just in case.
    Cheers
     
  7. CoCoNutti

    CoCoNutti

    Joined:
    Nov 30, 2009
    Posts:
    513
    Hi again.
    I have a cross-platform build and I'm currently working in iOS/win standalone. During normal play of game in Editor, all is fine. However, when I try to build for iOS/Win I get the following error during build process:

    It's pointing at :
    Code (csharp):
    1.  
    2.        bool getControllerButtonState(EasyInputConstants.PLAYER_NUMBER player, EasyInputConstants.CONTROLLER_BUTTON button)
    3.  {
    4.    
    5.  
    Can you help?
    Thanks
     
  8. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    If you upgrade to the version that landed on the asset store last week this is resolved.
     
    CoCoNutti likes this.
  9. CoCoNutti

    CoCoNutti

    Joined:
    Nov 30, 2009
    Posts:
    513
    is that version 1.3? I've redownloaded again (I only purchased this last week) and still getting the same issue. Maybe store isn't showing latest version?
     
  10. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    Should be version 1.4. Do you see the following on the webpage?

    screen2.png
    If you do but it's not downloading local, perhaps try to delete the local unitypackage where unity stores all the downloads for the asset store and re-download?
     
  11. CoCoNutti

    CoCoNutti

    Joined:
    Nov 30, 2009
    Posts:
    513
    Ah, just realised I was logged into the store under a different account! Got it now, thank you!
     
  12. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    No problem, glad you got it working.
     
  13. uni7y

    uni7y

    Joined:
    Jul 23, 2012
    Posts:
    287
    Looking great!
    I have one question: do you plan to add a third person controller for tvOS? I'm busy with a game and have some troubles to control the third person player...
     
  14. CoCoNutti

    CoCoNutti

    Joined:
    Nov 30, 2009
    Posts:
    513
    Have another question - sorry for the barrage. I never use GUI for my menu/pause systems. (I hate it). I always use sprites, more specifically, 2D Toolkit. Question is, I've tried all day to get Touchpad working the same way that you have with your MasterScene - I have 4 buttons on the pause screen that I can toggle through using touchpad and then clicking when one highlighted. However, I can't find a way to either change the colour on highlight, press etc, nor can I do a sprite swap for these states, as the system needs a 'graphic'. Is there any other way?

    Thanks
     
    Last edited: Mar 23, 2016
  15. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    The premise of the first person example would also work for the third person perspective (tilt to aim, long presses for full rotation, etc.). The only thing that would need to change is the camera orbit functionality (to follow a circle path around the player). If you need this in your game you can certainly use the match orientation scripts logic and combine it with any code you have for your camera orbit for your third person game.
     
  16. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    Can't say that I've used 2D Toolkit before so I'm unfamiliar with the system they have setup for selecting things, navigation, or the states they expose for UI events (like hover, select, etc.). That being said all the Unity GUI navigation we provide is contained within EasyInputModule.cs (all the swiping, scrolling, etc.). If you call 2D Toolkits way of selecting instead of Unity's way it will navigate the same as the current one does.
     
    Last edited: Mar 23, 2016
  17. uni7y

    uni7y

    Joined:
    Jul 23, 2012
    Posts:
    287
    Great... then I have to buy it I guess :)
    Thanks for the fast reply!
     
  18. CoCoNutti

    CoCoNutti

    Joined:
    Nov 30, 2009
    Posts:
    513


    I don't use the 2D Toolkit for their UI system either. I did have a quick go with their hover event on a sprite, but didn't register at all. Is there a way for me to access the hover event in TVOS?
     
  19. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    Not sure what you mean by hover event in TVOS. Events like hover, selected, and the rest aren't part of the operating system they are part of the UI framework (2D toolkit, Unity GUI, NGUI, etc.). I haven't used 2D toolkit before to know if it automatically does navigation for you (most 3rd party assets don't). In general, assuming that it doesn't do automatic navigation you're going to need to tell 2D toolkit when something is hovered over, selected, etc.

    I glanced at 2D toolkit's documentation and there certainly is an API to trigger these (OnToggleHover, IsOver, etc). If you are using the mouse pointer approach you originally talked about then when your raycasts hit a button you would call the appropriate 2D toolkit method. If your using the more swipe based navigation like is provided in our Unity GUI input module you would call the appropriate 2D toolkit method when swipes or other events occur. I haven't used 2D toolkit before so if you have questions on their appropriate methods to call and what needs to be passed you'll probably need to ask the author of 2D toolkit.

    Hope that helps.
     
    CoCoNutti likes this.
  20. Mark-Sweeney

    Mark-Sweeney

    Joined:
    Feb 21, 2010
    Posts:
    172
    Hey Greg - Is there a way to tell whether a click is from the siri remote or from a mifi controller? Both are using the X button for input.

    I'm adding a controller option to a game with TVOS Input Helper, but I need to change some text & and image depending on whether a button was pushed using the Siri remote or the gamepads controller.

    Thanks!
     
  21. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    Yeah, you can something like the following from any of the callbacks in the below example its the left stick but the same would apply to buttons. This is a runtime feature and doesn't make much sense in the editor which is why I've surrounded it with the platform defines, if you leave them off when you test in editor it will always emulate like player 1 (your mouse/keyboard) is the siri remote.

    Code (CSharp):
    1. void localLeftStick(ControllerAxis axis)
    2. {
    3.     #if !UNITY_EDITOR && UNITY_TVOS
    4.             if (axis.player == EasyInputHelper.siriRemotePlayer)
    5.             {
    6.                 //do your stuff here
    7.             }
    8.     #endif
    9. }
     
    Last edited: Jul 13, 2016
  22. Mark-Sweeney

    Mark-Sweeney

    Joined:
    Feb 21, 2010
    Posts:
    172
    Thank you! That helped me figure it out.

    For anyone else, here's code I wrote for testing for input for the A button (I know I wrote X button above, but that was a brain-fart.)
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.UI;
    4. using EasyInput.Core;
    5.  
    6. public class SiriOrController : MonoBehaviour
    7. {
    8.     void OnEnable()
    9.     {
    10.         EasyInputHelper.On_ClickEnd += localClickEnd;
    11.     }
    12.  
    13.     void OnDestroy()
    14.     {
    15.         EasyInputHelper.On_ClickEnd -= localClickEnd;
    16.     }
    17.  
    18.     void localClickEnd(ButtonClick button)
    19.     {
    20.         #if !UNITY_EDITOR && UNITY_TVOS
    21.         if (button.button == EasyInputConstants.CONTROLLER_BUTTON.AButton)
    22.         {
    23.             if(button.player !=EasyInputHelper.siriRemotePlayer)
    24.             {
    25.                 Debug.Log("Controller Input Hit");
    26.             }
    27.             else
    28.             {
    29.                 Debug.Log("Siri Input Hit");
    30.             }
    31.         }
    32.         #endif
    33.     }
    34. }
    35.  
     
    greggtwep16 likes this.
  23. mhdmnaina

    mhdmnaina

    Joined:
    Sep 19, 2013
    Posts:
    3
    Hi.... Currently i am working in a TVOS Game.. So, I downloaded the plugin “TVOS EASY INPUT HANDLER”. Its working well and good.. But i have 1 doubt in that… In the Scene in Unity “MasterExample”, We are changing the buttons by using siri remote in TVOS.. It shows little grey cool to think that the button is selected… Its not clear.. Is it possible to change the colour of the button when we select the button using the siri remote… Its very urgent work for me…Could any one please reply as soon as possible..I am waiting for your reply.. If possible reply to my mail id which is "mhdmnaina@gmail.com".
     
  24. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    Hi, The example scenes you mention just use the default Unity UI system so your question isn't really related to my product but here is the answer anyway. In the below picture (slightly outdated but you will see similar in current Unity) you will see that any button has the following section in the inspector (below the rect transform and other items). The 4 colors you see there control the color and the transparency on the 4 typical states of a button (normal, highlighted, pressed, and disabled). In the current version of this you can also change the sprites if you wish for any of the states. Simply change the color to what you want and it will have the desired effect.

    button.png

    I have sent the same to your email as requested, but it usually isn't wise to post your mail on the internet directly so you may want to edit that.
     
  25. Mark-Sweeney

    Mark-Sweeney

    Joined:
    Feb 21, 2010
    Posts:
    172
    I use Animation for Button Transitions, and create animation states. Makes it really easy to see.
    I did Normal mode at 80% scale, Highlighted (selected) at 100% scale.
    Pressed goes from 100% to 120% to 100%.
     
  26. SaltwaterAssembly

    SaltwaterAssembly

    Joined:
    Mar 8, 2016
    Posts:
    95
    Hi, wondering if we're able to move our curser object around the screen (2D home screen) using the touchpad, beyond the touchpad's physical bounds. Our game is for little kids, and we want to make it easy to move the curser around the screen without having to lift their finger to move across the touchpad again once they get to the edge. So, when the finger hits the edge of the touchpad, the curser keeps moving in that direction until they change the direction of their finger on the pad, or lift their finger. Right now I can only get it to move until your finger physically reaches the end of the touchpad and have to lift then move again from centre of the pad - it's a bit awkward for me, so for kids, it'll be harder. It's almost like I'd like the bounds of the physical touchpad to match the bounds of the screen in a sense.

    Is this possible?

    Thanks
     
  27. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    Not sure if I fully understand the usecase but yes this is possible but there isn't a provided control for it you would have to modify the touchpad control to fit your needs and save it as your custom file.

    As far as the usecase goes it's not clear to me if you want the square pad to mirror the rectangular TV meaning all the way left on the pad is all the way left on the screen. If it is you can simply treat the -1 value as 0 pixel coordinates and 1 as Screen.Width and it will accomplish this. That being said I don't think this will feel good because when you convert a square to a rectangle your up/down swipes won't match your left/right ones (a 16:9 screen is almost double as wide as it is tall). In essence your left/right swipes will be almost twice as fast as the up/down ones.

    If you instead meant keep the swipes as is but once you pass some threshold on the remote turn it into a dpad and keep going this might feel ok depending on the app not sure if its intuitive though. You'd essentially be kind of combining the touchpad control and the dpad control at some threshold (for example if the values get higher than .8 or lower than -.8).

    Hope this helps. Certainly let me know if I'm misunderstanding.
     
  28. SaltwaterAssembly

    SaltwaterAssembly

    Joined:
    Mar 8, 2016
    Posts:
    95
    Yes, the above is close to what we're aiming for. But you're right, it may not feel intuitive. We'll have to experiment or rethink this. Thank you.
     
  29. GamerSuji

    GamerSuji

    Joined:
    Aug 1, 2015
    Posts:
    8
    Hi, Before I buy this I have a small doubt, I was working on the input manager myself but I could not seem to separate Input.GetButton from Input.GetButtonUp.
    For some reason, even the Input.GetbuttonUp works like Input.Getbutton, need to know whether you allow different Implementations for button input such as GetbuttonDown, GetbuttonUp and Getbutton, which I could use with the TV remote.
     
  30. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    The product just wraps the Unity input manager so as far as that is concerned you wouldn't see any difference. In general if you are just using one of the predefined components that you see in the documentation online as is you don't need to mess with any of it. However if you plan on modifying some, it functions the same as Unity input manager.