# Unity-iOS-Bridge **Repository Path**: youngfun2yf/Unity-iOS-Bridge ## Basic Information - **Project Name**: Unity-iOS-Bridge - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-05-03 - **Last Updated**: 2021-05-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Unity iOS Bridge ## Installation ### Unity Package Manager ```json { "dependencies": { "com.candycoded.unity-ios-bridge": "https://github.com/CandyCoded/Unity-iOS-Bridge.git#v1.1.0" } } ``` ## Contents - [Accessibility](#accessibility) - [Alerts](#alerts) - [Permission](#permission) - [Photos](#photos) - [Settings](#settings) - [View](#view) ## Documentation ### Accessibility Make your apps accessible to everyone, including people with disabilities. #### `IOSUIAccessibilityIsAssistiveTouchRunning` Returns a Boolean value indicating whether the system preference for AssistiveTouch is enabled. ```csharp #if UNITY_IOS && !UNITY_EDITOR Debug.Log(CandyCoded.UnityIOSBridge.Accessibility.IOSUIAccessibilityIsAssistiveTouchRunning()); // true #endif ``` Ref: #### `IOSUIAccessibilityIsVoiceOverRunning` Returns a Boolean value indicating whether VoiceOver is running. ```csharp #if UNITY_IOS && !UNITY_EDITOR Debug.Log(CandyCoded.UnityIOSBridge.Accessibility.IOSUIAccessibilityIsVoiceOverRunning()); // true #endif ``` Ref: #### `IOSUIAccessibilityIsSwitchControlRunning` Returns a Boolean value indicating whether Switch Control is enabled. ```csharp #if UNITY_IOS && !UNITY_EDITOR Debug.Log(CandyCoded.UnityIOSBridge.Accessibility.IOSUIAccessibilityIsSwitchControlRunning()); // true #endif ``` Ref: #### `IOSUIAccessibilityIsShakeToUndoEnabled` Returns a Boolean value indicating whether the system preference for Shake to Undo is enabled. ```csharp #if UNITY_IOS && !UNITY_EDITOR Debug.Log(CandyCoded.UnityIOSBridge.Accessibility.IOSUIAccessibilityIsShakeToUndoEnabled()); // true #endif ``` Ref: #### `IOSUIAccessibilityIsClosedCaptioningEnabled` Returns a Boolean value indicating whether closed captioning is enabled. ```csharp #if UNITY_IOS && !UNITY_EDITOR Debug.Log(CandyCoded.UnityIOSBridge.Accessibility.IOSUIAccessibilityIsClosedCaptioningEnabled()); // true #endif ``` Ref: #### `IOSUIAccessibilityIsBoldTextEnabled` Returns a Boolean value indicating whether bold text is enabled. ```csharp #if UNITY_IOS && !UNITY_EDITOR Debug.Log(CandyCoded.UnityIOSBridge.Accessibility.IOSUIAccessibilityIsBoldTextEnabled()); // true #endif ``` Ref: #### `IOSUIAccessibilityDarkerSystemColorsEnabled` Returns a Boolean value indicating whether darken colors is enabled. ```csharp #if UNITY_IOS && !UNITY_EDITOR Debug.Log(CandyCoded.UnityIOSBridge.Accessibility.IOSUIAccessibilityDarkerSystemColorsEnabled()); // true #endif ``` Ref: #### `IOSUIAccessibilityIsGrayscaleEnabled` Returns a Boolean value indicating whether grayscale is enabled. ```csharp #if UNITY_IOS && !UNITY_EDITOR Debug.Log(CandyCoded.UnityIOSBridge.Accessibility.IOSUIAccessibilityIsGrayscaleEnabled()); // true #endif ``` Ref: #### `IOSUIAccessibilityIsGuidedAccessEnabled` Returns a Boolean value indicating whether the app is running in Guided Access mode. ```csharp #if UNITY_IOS && !UNITY_EDITOR Debug.Log(CandyCoded.UnityIOSBridge.Accessibility.IOSUIAccessibilityIsGuidedAccessEnabled()); // true #endif ``` Ref: #### `IOSUIAccessibilityIsInvertColorsEnabled` Returns a Boolean value indicating whether inverted colors is enabled. ```csharp #if UNITY_IOS && !UNITY_EDITOR Debug.Log(CandyCoded.UnityIOSBridge.Accessibility.IOSUIAccessibilityIsInvertColorsEnabled()); // true #endif ``` Ref: #### `IOSUIAccessibilityIsMonoAudioEnabled` Returns a Boolean value indicating whether system audio is set to mono. ```csharp #if UNITY_IOS && !UNITY_EDITOR Debug.Log(CandyCoded.UnityIOSBridge.Accessibility.IOSUIAccessibilityIsMonoAudioEnabled()); // true #endif ``` Ref: #### `IOSUIAccessibilityIsReduceMotionEnabled` Returns a Boolean value indicating whether reduce motion is enabled. ```csharp #if UNITY_IOS && !UNITY_EDITOR Debug.Log(CandyCoded.UnityIOSBridge.Accessibility.IOSUIAccessibilityIsReduceMotionEnabled()); // true #endif ``` Ref: #### `IOSUIAccessibilityIsReduceTransparencyEnabled` Returns a Boolean value indicating whether reduce transparency is enabled. ```csharp #if UNITY_IOS && !UNITY_EDITOR Debug.Log(CandyCoded.UnityIOSBridge.Accessibility.IOSUIAccessibilityIsReduceTransparencyEnabled()); // true #endif ``` Ref: #### `IOSUIAccessibilityIsSpeakScreenEnabled` Returns a Boolean value indicating whether speaking the screen is enabled. ```csharp #if UNITY_IOS && !UNITY_EDITOR Debug.Log(CandyCoded.UnityIOSBridge.Accessibility.IOSUIAccessibilityIsSpeakScreenEnabled()); // true #endif ``` Ref: #### `IOSUIAccessibilityIsSpeakSelectionEnabled` Returns a Boolean value indicating whether speaking the selection is enabled. ```csharp #if UNITY_IOS && !UNITY_EDITOR Debug.Log(CandyCoded.UnityIOSBridge.Accessibility.IOSUIAccessibilityIsSpeakSelectionEnabled()); // true #endif ``` Ref: ### Alerts #### `IOSUIAlertController` ```csharp #if UNITY_IOS && !UNITY_EDITOR CandyCoded.UnityIOSBridge.Alert.IOSUIAlertController("Title", "message", () => { Debug.Log("OK"); }); #endif ``` ```csharp #if UNITY_IOS && !UNITY_EDITOR CandyCoded.UnityIOSBridge.Alert.IOSUIAlertController("Title", "message", () => { Debug.Log("OK"); }, () => { Debug.Log("Cancel"); }); #endif ``` ### Permission #### `IOSPermissionCameraOK` ```csharp #if UNITY_IOS && !UNITY_EDITOR Debug.Log(CandyCoded.UnityIOSBridge.Permission.IOSPermissionCameraOK()); // true #endif ``` Ref: ### Photos #### `IOSImageAddToGallery` Note: This requires `NSPhotoLibraryAddUsageDescription` to be in the `Info.plist` file with a value. Note: `Screenshot.Save` uses the internal method `ScreenCapture.CaptureScreenshot` which returns before the file is saved to the device. Make sure the file exists before calling `IOSImageAddToGallery` by using a coroutine to wait until the file exists. ```csharp public void TakeScreenshot() { StartCoroutine(TakeScreenshotCoroutine()); } private static IEnumerator TakeScreenshotCoroutine() { var screenshotFilePath = Screenshot.Save(); Debug.Log($"Saved screenshot to {screenshotFilePath}"); while (!File.Exists(screenshotFilePath)) { yield return null; } yield return new WaitForEndOfFrame(); #if UNITY_IOS && !UNITY_EDITOR CandyCoded.UnityIOSBridge.Photos.IOSImageAddToGallery(screenshotFilePath); Debug.Log("Saved to gallery."); #endif } ``` Ref: Ref: ### Settings #### `IOSIsLowPowerModeEnabled` A Boolean indicating whether Low Power Mode is enabled on an iOS device. ```csharp #if UNITY_IOS && !UNITY_EDITOR Debug.Log(CandyCoded.UnityIOSBridge.Settings.IOSIsLowPowerModeEnabled()); // false #endif ``` Ref: #### `IOSUIImpactFeedbackGenerator` ```csharp #if UNITY_IOS && !UNITY_EDITOR CandyCoded.UnityIOSBridge.Settings.IOSUIImpactFeedbackGenerator(); #endif ``` ```csharp #if UNITY_IOS && !UNITY_EDITOR CandyCoded.UnityIOSBridge.Settings.IOSUIImpactFeedbackGenerator("light"); CandyCoded.UnityIOSBridge.Settings.IOSUIImpactFeedbackGenerator("medium"); CandyCoded.UnityIOSBridge.Settings.IOSUIImpactFeedbackGenerator("heavy"); #endif ``` Ref: ### View #### `IOSSafeAreaInsets` The insets that you use to determine the safe area for this view. ```csharp #if UNITY_IOS && !UNITY_EDITOR Debug.Log(CandyCoded.UnityIOSBridge.View.IOSSafeAreaInsets()); // {top: 0, left: 0, right: 0, bottom: 0} #endif ``` Ref: