Android and iOS

Users can create Enoch avatars seamlessly in a WebView displayed within a Unity application.

Prerequisites

Enoch SDK. You need the Enoch SDK for Unity installed in your project to retrieve avatars. See the Quickstart guide for instructions.

Deploying the app. In order to test your WebView app, you have to deploy it to a physical or virtual device. See the Unity documentation on how to do that.

  • Android development with Unity documentation.

  • iOS development with Unity documentation.

Project setup (Android and iOS)

Creating a Scene with a WebView in your Unity project is the same for Android and iOS.

  1. Create or open your Unity project.

  2. Import the Enoch SDK into your project, if you haven't done so already.

  3. Navigate to Assets > Plugins > Enoch avatars > Examples > Webview Examples.

  4. Open the WebviewExample Scene.

  5. In the Hierarchy, notice the WebviewTest game object. It has a WebViewExample script component, as well as a Canvas with some buttons.

  6. Open and examine the WebviewExample script. Notice the following.

    • Variables for a GameObject avatar, as well as fields for the UI elements.

    • Start() adds Listeners to the buttons.

    • DisplayWebView() creates a Webview for the Avatar Creator if there isn't one.

    • OnAvatarCreated(). Once the avatar has been created by the user, this callback destroys any existing avatar, instantiates an AvatarLoader, sets callbacks for success and failure, and then loads the current avatar.

    • HideWebView() hides the WebView.

    • Destroy() cleans up the listeners.

  7. Open the Build Settings to set up deployment for your chosen platform.

Deploy on Android

  1. In Build Settings, set the Platform to Android.

  2. Check Development Build.

  3. Click Player Settings....

  4. Find Player > Other Settings > Identification.

    • Check Override Default Package Name.

    • Set a unique Package Name in the format com.YourCompanyName.YourProductName.

  5. Find Player > Other Settings > Under Configuration > Camera Usage Description and put some descriptive text in this mandatory field.

  6. Find Player > Other Settings > Under Configuration > Microphone Usage Description and put some descriptive text in this mandatory field.

  7. Close the Project Settings.

  8. On your device, turn on USB debugging in your Developer Options settings.

  9. Connect your device to your computer.

  10. Click Build and Run.

  11. Once the app opens on your device, click the button. Give permissions, and off you go.

Alternatively, you can build the APK and deploy it on your own.

For release builds, see the Unity and Android documentation.

Troubleshooting

  • If you don't have a subdomain, this warning will pop up, and you can click Continue with 'demo' subdomain.

  • If your package name does not comply with the required format, you will get this warning and can't continue until you fix it.

Deploy on iOS

  1. In Build Settings, set the Platform to iOS.

  2. Select Debug and check Development build.

  3. Find Player > Other Settings > Identification.

    • Check Override Default Package Name.

    • Before you build your Project for iOS, make sure that you set the Bundle Identifier.

    • Set a Package Name in the format com.YourCompanyName.YourProductName.

    • Fill in the Signing Team ID (not required for Debug builds to complete).

    • You can also choose whether your app targets the simulator or an actual device. To do this, change the SDK version** >> Target SDK to Simulate SDK or Device SDK.

  4. Find Player > Other Settings > Under Configuration > Camera Usage Description and put some descriptive text in this mandatory field.

  5. Find Player > Other Settings > Under Configuration > Microphone Usage Description and put some descriptive text in this mandatory field.

  6. Close Project Settings.

  7. Click Build.

  8. In the file explorer, find your Builds folder and in it the Unity-iPhone.xcodeproj.

Publication follows the the standard procedure for publishing Unity projects to iOS.

Publishing for iOS is different from publishing for platforms such as Windows or macOS. Due to restrictions in access to development tools, Unity can only create an Xcode project for an iOS game or app and not build the binary directly.

See these resources:

Last updated