API Manager is a Unity C# class that serves as a manager for handling API requests and responses. It provides a straightforward way to send GET requests to specified API endpoints, with callbacks for successful responses and error handling. The class follows the Singleton pattern for ease of use and ensures persistence across scenes.


Release v1.0.0

https://github.com/swzwij/Code-Crate/releases/tag/API-Manager-v1.0.0


Installation

Importing a Unity Package:

  1. Download the Package: Locate the Unity package you want to import. This could be from the Unity Asset Store or a developer's website. Download the .unitypackage file.

  2. Import into Unity: There are two ways to import the package into your Unity project:

  3. Import Options (Optional):

    A window will appear showing the contents of the package. By default, all items are selected for import. You can uncheck any files or folders you don't want to import into your project.

  4. Click Import: Once you're happy with the selection, click Import to begin importing the package files into your project.


Usage

Sending GET Requests

Use the GetCall method to send a GET request to the specified API endpoint.

// Create an instance of your API request configuration class
APIRequest apiRequest = new YourAPIRequestClass(); 
apiManagerInstance.GetCall<YourResponseType>(apiRequest, OnComplete, OnFailure);

Callbacks

Callback Description
OnComplete Callback invoked upon a successful response.
OnFailure Callback invoked when the request fails or encounters an error.

Example Callbacks