Guidelines for running sample codes
This article describes how to quickly run the sample source code and experience basic audio and video calling services.
Set up the development environment
Make sure your development environment meets the following technical requirements:
Install Unity 2018.4.21f1 or above. If it is not installed, you can download the Unity Hub at Unity official website, and then install the Unity version you need (if not clear, it is recommended that you install the latest LTS Version). When downloading, it is recommended to select the corresponding Plaforms module to download together according to the platform you need to run on. Take the installation on macOS as an example:
Select the corresponding development environment or device according to the platform on which the sample code needs to run:
Requirements for running the Android sample source code: Android version is not less than 4.4, and an Android device or emulator that supports audio and video (recommended real device), if it is a real device, please enable the "Allow debugging" option.
Requirements for running the iOS sample source code: Xcode 13.0 or above, iOS 9.0 or above and an iOS device or simulator that supports audio and video (recommended real machine).
Requirements for running macOS sample source code: macOS 10.11 or above, and a macOS device that supports audio and video.
Requirements to run the Windows sample source code: Windows 7 or above, and a Windows device that supports audio and video; and Visual Studio 2015 or above installed.
Make sure the network connection of the running device is normal.
Make sure Unity has the Platfroms module installed for the platform it needs to run on. If Unity is already installed, but the relevant Platroms modules are not installed, you need to download the corresponding modules. Take the installation on macOS as an example: Open Unity Hub, click the "Install" option on the left, select the version of Unity you want to install, and click the upper right corner. Click the icon to select the "Add Module" option to check and download the corresponding module.
Run the sample code
1. Get the AppID and AppSign
Get the AppID and token in ZEGOCLOUD Console for SDK initialization.
To run the sample code, remember to replace the AppID and token in the sample codes with the AppID and token you get in the previous step.
2. Download the ZegoExpress SDK
The downloaded sample source code is missing the SDK, you need to download the SDK package first, and unzip it.
Copy the decompressed SDK package to the "Assets" directory of the project; and do additional processing according to the platform to be run, otherwise the App will fail to build.
3. Open the
Assets/ZegoExpressExample/KeyCenter.cs, fill in the
4. Click the "Projects" tab of Unity Hub, click "Open" in the upper right corner, and select the directory where the sample source code is located
5. After opening, a prompt may pop up: "Editor version not installed", the version of Unity Editor used by the sample source project cannot be found. At this point, select another Unity Editor version and specify the Unity version you are using
6. After opening the project, select "HomePage" under the "Project > Assets > Scenes" directory in the lower left corner, double-click, and then select the "Game" tab, you can see the scene of the example source code home page
7. In the upper menu bar, select "File > Build Settings"
8. Select the platform in "Platform", and click "Switch Platform" in the lower right corner to switch the platform to be run
9. Start the run
Run to Android device:
a. Referring to step 7, switch "Platform" to "Android" platform, click "Player Settings", and set the package name and other configurations.
b. After completing the setup, connect the Android device and click "Build And Run".
Run to iOS device:
a. Referring to step 7, switch "Platform" to "iOS" platform, click "Build" to save the iOS project locally, and open the local project through Xcode.
b. In the opened Xcode project, open the "Signing & Capabilities" tab of the "Unity-iPhone" Target, first make sure "Automatically manage signing" is checked, then switch "Team" to your own Team, and then modify the "Bundle Identifier" " is the custom Bundle ID.
c. Select the "Info.plist" file to add camera and microphone permissions.
d. Click the Run button to run the example Demo.
Please note that when running to an iOS device, if the following error occurs:
no suitable image found. Did find: /private/var/containers/Bundle/Application/3CC0EE65-89C9-45F5-8E22-A4AC194DF260/hello.app/Frameworks/UnityFramework.framework/Frameworks/ZegoExpressEngine.framework/ZegoExpressEngine: code signature in (/private/var/containers/Bundle/Application/3CC0EE65-89C9-45F5-8E22-A4AC194DF260/hello.app/Frameworks/UnityFramework.framework/Frameworks/ZegoExpressEngine.framework/ZegoExpressEngine) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
Please refer to Integrate the SDK about exporting iOS Xcode project to integrate ZegoExpressEngine.framework to deal with this error.
Run to macOS device:
a. Referring to step 7, switch "Platform" to "macOS" platform, select the architecture to be built, such as Intel + Apple silicon, and then click "Build" to generate the app locally.
b. After generating an application on macOS, double-click to run it.
Run to Windows device:
a. Referring to step 7, switch "Platform" to "Windows" platform, select the architecture to be built, note that the architecture selected here should be consistent with the SDK architecture retained in step 1, and then click "Build" Generate the app locally.
b. On Windows devices, click the .exe file in the project to run it.
Experience the audio and video functions
We recommend you run your project on a real device. If your app runs successfully, you should hear the sound and see the video captured locally from your device.
To test out the real-time audio and video features, visit the ZEGO Express Web Demo, and enter the same
RoomID to join the same room. If it runs successfully, you should be able to view the video from both the local side and the remote side, and hear the sound from both sides as well.
In audio-only scenarios, no video will be captured and displayed.