[Released] iOS 3D Touch Plugin & Touch Radius Input Plugin (plug&play)

2322569--160933--3dtouch_forum.png
iOS 3D Touch (Force Touch) & Touch Radius Input Plugin

This plugin is a way to integrate iOS 3D touch (pressure touch) or touch radius into your game before Unity officially supports this feature (please note that Unity 5.2.3f1 added pressure and maximumPossiblePressure properties to Touch class). No Objective-c skills needed, no changes to Unity player. Simply add plugin files to your project and get touches on C# side as you would by using Input.touches.

Very few allocations and very fast performance thanks to binary serialization/deserialization of touch data. No strings allocations or other memory hungry operations.

Be first to deploy games for iPhone 6s / iPhone 6s Plus and iPad Pro.

Features:

  • Full documented source code
  • Full support for iOS 3D Touch API (including iPencil pressure support)
  • Full support for iOS Touch Radius
  • Backwards compatibility to work on iOS 5 and above
  • No objective-c knowledge required - touch data is provided as list of C# objects
  • Easy to understand, documented example project displaying all the features and fallback methods
  • InputManager class to easily handle native touch, unity touch and mouse inputs at the same time

Compatibility:

  • Works on all iOS devices
  • iOS 5 and above for position and delta position data
  • iOS 8 and above for touch radius data
  • iOS 9 and above for 3d touch data (requires hardware support)
  • Unity 4.6 Pro
  • Unity 5 Free and Pro

Considerations:

  • Unity documentation states that managed-to-unmanaged calls are CPU intensive on iOS and should be limited to one call per frame. For best performance this plugin uses 1 call of this type per frame. Since only new hardware is supporting 3d touch and you can disable plugin on older devices no need to worry, but I think it’s important to mention this.

Support and feedback:

  • Use this thread to ask questions - I’m more than happy to answer them.
  • Send invoice number to support@pinstudios.com (with subject “iOS 3D Touch Plugin”) to subscribe to beta downloads of future releases.
  • If you need urgent help, send requests to support@pinstudios.com
  • Your feedback is highly appreciated so don’t hesitate to send it to support email too!

FAQ:

1. Does Plugin support Unity 4.6?
Yes it does. However since plugin contains Objective-C code it requires Unity 4.6 Pro. It works with both - free and paid - versions of Unity 5.

2. Does Plugin support touch radius?
Yes, it supports touch radius since version 1.2.

3. Why is value for maxForce is 6.6666667 and not 1?
This was decided by apple. I assume that this value will change in the future for other devices that will support 3D touch (including iPad Pro with iPencil). You can assume that force value of 1f is the force of the average touch. Using normalized force value is wrong, because when maxForces will start to differ you won’t have a clear reference for what is “pressure of the regular touch”.

4. Is there a way to trigger the haptic feedback?
Unfortunately Apple doesn’t provide such API.

5. How can I test 3D touch on iPhone Simulator?
Unfortunately You can’t. At the moment iPhone simulator doesn’t support 3d touch.

6. Isn’t this supported by Unity?
Unity added partial support for 3D Touch in 5.2.3f1. Older versions do not support it and plugin is the only way to add 3d touch to games built using those versions of Unity. This plugin has few other advantages:

  1. Touch radius support
  2. Ability to determine if 3D touch or Touch Radius is supported on current device
  3. Callback for event when user switches 3D Touch on or off in accessibility settings
    I think that this plugin is no longer required for majority of Unity developers, however it may be life saver for those very few who still need it.
1 Like

Plugin just went live. You can obtain it at: Unity Asset Store - The Best Assets for Game Making.

Added FAQ section in the first post.

Plugin version 1.2.2 went live today.

This version adds official support for Unity 4.6 Pro and Touch Radius. Improvements in code comments, documentation and fixes to the bugs that were found within last few weeks.

Is it possible to implement the pressure touch on App Icon, like we did on Notes App and Instagram App Icons in iPhone 6S & 6S+?

Hello, the short answer is “not with this plugin”. This plugin focuses on exposing touch pressure / radius inside the app.

Static shortcuts are defined in info.plist file in the xcode project, dynamic properties can be added via code, but it’s not available in this plugin.

Hi! Have you tested your plugin on Unity 5.2.2?

Hello, sorry for such late reply. I haven’t, is there something wrong with that version of Unity? I would check into it. Plugin works fine with all versions from 4.6.2 - 5.2.1p2. Looking forward to hearing from you.

Hello @ina , I have tested the plugin today and it works fine with unity 5.2.2p2. I suppose you just wanted to make sure that everything works rather than reporting a problem. Hope this helps.

Watch out for copycat plugins appearing on the store using same color scheme and same icons as this plugin. Being copied means that this plugin has to be good! :slight_smile:

We have been using this plugin fine with iOS 8 and 9, but have run into an issue with iOS7. We are getting this crash consistently:
Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: '-[UnityView traitCollection]: unrecognized selector sent to instance

With the partial stack:
-[AlternativeInput getForceTouchState] (AlternativeInputUnity.mm:197)
+[AlternativeInput getForceTouchState] (AlternativeInputUnity.mm:64)
ForceTouchPlugin_GetForceTouchState_m9693 (Bulk_Assembly-CSharp_8.cpp:15714)

Any ideas?

Just noticed there is an update, does this fix it?

Yes, this was fixed in 1.2 which is available for ~2 weeks now. Version 1.2 fixes few important bugs so it’s important to upgrade to 1.2.

When you update, please note that there’s an option for Touch Radius in 1.2 and that ForceTouchState enum value OldiOS chanded to IncompatibleOS. This is the only refactoring needed when you migrate to 1.2+. Hope this helps.

Has iPencil support been tested?

This plugin will report iPencil pressure and maxpressure like it does with 3d touch. Codewise pencil is just another touch with additional set of properties therefore it wasn’t explicitly tested. Please note that this plugin only reports pressure for the pencil, and not other pencil related properties like estimated touches and tilt.

Do you plan to include tilt?

TL;DR I don’t think I will add other pencil properties to this plugin to keep it as lightweight and as easy to use as possible.

Pencil API is much more difficult than tilt & pressure. Pencil has these extra properties:
altitudeAngle Property (New in iOS 9.1)
azimuthAngleInView
azimuthUnitVectorInView
estimatedProperties
estimationUpdateIndex
estimatedPropertiesExpectingUpdates
(see UITouch | Apple Developer Documentation for explanations what each of them mean)

Implementing this API partially doesn’t make sense and implementing it fully (including estimated properties) would most likely change the workflow of the plugin. Pencil workflow will most likely require more CPU power (even if just a little) and add complexity to usage (you can’t simply do plugin.getnativetouches() any more because you need to differentiate estimated touches from confirmed ones). Therefore, since many of customers who buy this plugin only need 3d touch, making plugin less suitable for them wouldn’t be a smart move.

I am considering to create a separate plugin for iPencil with an option to upgrade from this plugin. The new plugin might have 2 packages in it - one for 3d touch only, the other for pencil and 3d touch.

Would be interested in the Pencil plugin - there does not appear to be one so far

Thank you for letting me know. This of course encourages to work on one even if it will only have very limited sales (due to what I believe very low demand).

I’d be fine paying $100 for it :slight_smile: - if it is the only Apple Pencil plugin in the store, I am sure you will get more sales - especially if it is priced reasonably.

Especially if it’s out by next week when the Apple Pencil is released!