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.
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:
Touch radius support
Ability to determine if 3D touch or Touch Radius is supported on current device
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.
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.
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.
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!
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)
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.
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.
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.
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 - 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!