Skip to content
Usef Farahmand edited this page Aug 5, 2024 · 3 revisions

Home

Welcome to the UAPI Wiki! This documentation will guide you through the features, installation, and usage of the UAPI library.

Getting Started

Installation

Git URL

UAPI supports Unity Package Manager. To install the project as a Git package, follow these steps: In Unity, open Window -> Package Manager. Press the + button, choose "Add package from git URL...". Enter "https://github.com/UModules/UAPI.gitupm" and press Add.

Unity Package

Alternatively, you can add the code directly to the project:

  1. Clone the repo or download the latest release.
  2. Add the UAPI folder to your Unity project or import the .unitypackage.

Manifest File

You can also install via git URL by adding this entry to your manifest.json:

"com.umodules.uapi": "https://github.com/UModules/UAPI.git#upm"

Features

  • Easy Integration: Simplifies the integration of APIs into your applications.
  • Comprehensive Documentation: Detailed documentation to help you get started quickly.
  • Modular Architecture: Highly modular design allows for easy customization and extension.
  • Robust Testing: Includes a suite of tests to ensure reliability and stability.

Usage

Sample Usage

This example demonstrates how to create an API manager and send a request: namespace UAPIModule.Tests { public class APIManager : RequestSender { public APIManager(INetworkLoadingHandler loadingHandler) : base(loadingHandler) { } }

public class APITest : MonoBehaviour
{
    public APIConfig apiConfig;
    private INetworkLoadingHandler loadingHandler;

    private void Awake()
    {
        loadingHandler = NetworkLoadingHandlerCreator.CreateAndGet();
    }

    private async void Start()
    {
        APIManager apiManager = new APIManager(loadingHandler);
        RequestFeedbackConfig feedbackConfig = RequestFeedbackConfig.InitializationFeedback;

        NetworkResponse<string> response = await apiManager.SendRequest(apiConfig, feedbackConfig, null);
        if (response.isSuccessful)
        {
            Debug.Log(response.data);
        }
        else
        {
            Debug.LogError($"Request failed: {response.errorMessage}");
        }
    }
}

}

License

This project is licensed under the MIT License. See the LICENSE file for details.

Clone this wiki locally