This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #if TARGET_OS_IOS || TARGET_OS_TV | |
| static CHHapticEngine* cachedHapticEngine = nil; | |
| static GCController* cachedController = nil; | |
| bool Native_VibrateController(float intensity, float duration) | |
| { | |
| // Clamp input | |
| intensity = fmaxf(0.0f, fminf(intensity, 1.0f)); | |
| duration = fmaxf(0.02f, duration); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #if TARGET_OS_IOS | |
| static CHHapticEngine* hapticEngine = nil; | |
| void Native_PlayHaptic(float intensity, float duration) | |
| { | |
| // Core Haptics available? | |
| if (@available(iOS 13.0,*)) { | |
| NSError *error = nil; | |
| if (!hapticEngine) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if UNITY_ANDROID | |
| // Cache Android vibrator objects to avoid allocations on every call | |
| private static AndroidJavaObject cachedVibrator = null; | |
| private static bool supportsAmplitudeControl = false; | |
| private static bool vibratorInitialized = false; | |
| private static void InitializeAndroidVibrator() | |
| { | |
| if (vibratorInitialized) | |
| return; |