Preperation

Before diving into the world of advanced AI with OpenAI with unity, there are a few prerequisites and setup steps that you need to complete. These preparations ensure that your Unity environment is ready to seamlessly integrate with OpenAI's technologies, allowing you to focus on creating innovative and engaging content.

1. Unity Version Compatibility

Ensure that your Unity version is compatible with the OpenAI with unity asset. We recommend using Unity 2020.3 LTS or later for optimal performance and compatibility. You can download the latest version of Unity from the Unity Hub.

2. Install Newtonsoft.Json

OpenAI with Unity utilizes Newtonsoft.Json for efficient JSON manipulation, which is essential for communicating with OpenAI's APIs. Unity Package Manager (UPM) provides a streamlined method for managing package dependencies. Follow these steps to install Newtonsoft.Json via UPM:

  1. Open the Unity Editor and navigate to the Window menu.

  2. Select Package Manager to open the Unity Package Manager.

  3. Click on the + button at the top left of the window, and select "Add package from git URL...".

  4. Since Newtonsoft.Json is not directly available as a UPM package from Unity, you will need to add a UPM-friendly fork or a wrapper of Newtonsoft.Json available on GitHub. For example, you can use https://github.com/jilleJr/Newtonsoft.Json-for-Unity.git. Paste this URL into the dialog box and click Add. Note: Ensure you are using a trusted and up-to-date repository.

  5. Unity will now download and install Newtonsoft.Json into your project.

Verify Installation:

  • After installation, Newtonsoft.Json should appear in the list of packages in the Package Manager. You can also verify the package is correctly added to your project by checking the Packages folder in your Unity Project window.

  • Ensure that the Newtonsoft.Json namespace is accessible by attempting to use it within your scripts. For example, you can try adding using Newtonsoft.Json; at the top of one of your C# script files to confirm it's recognized by Unity.

By following these steps, you will have successfully integrated Newtonsoft.Json into your Unity project using the Unity Package Manager, enabling efficient JSON handling for your "OpenAI with Unity" integration.

3. Install UniTask

UniTask is a high-performance, Unity-optimized library for managing asynchronous operations, crucial for handling AI tasks without blocking your game's performance. To install UniTask, follow these instructions:

  1. Visit the UniTask GitHub Repository: Go to Cysharp/UniTask on GitHub to access the project page.

  2. Download the Latest Release: As of 2024-04-01, the most recent release is version 2.5.4. You can download it directly from the releases section: UniTask 2.5.4.

  3. Import into Unity: After downloading, import the package into your Unity project. To do this, open Unity, navigate to Assets > Import Package > Custom Package, and select the downloaded UniTask package file.

4. API Key Configuration

To use OpenAI's services, you'll need an API key. For detailed instructions on getting an API key and setting up the API key within your project, please proceed to the next page.

Last updated