Skip to content

Quick Start Guide

Master web requests in Unity games with the RetroDev.Networking package. Seamlessly integrate web requests into your projects and elevate your network capabilities to new heights. Explore the comprehensive features below to master HTTP requests like a pro.

1. Setup and Usage

Integrate the RetroDev.Networking package into your project to simplify making HTTP requests. Here’s how you can use it:

2. Setting Custom Headers

Define custom headers for your web requests to include necessary authentication tokens and other information.

// Example for setting custom headers
var headers = new Dictionary<string, string>
{
{ "Authorization", "Bearer your_token_here" },
{ "Custom-Header", "custom_value" },
{ "User-Agent", "CustomUserAgent/1.0" }
};

3. Perform a GET Request

Retrieve data from a specified URL using the GET method.

// Example usage of GET request
RetroDevRequest.Get(getUrl, headers,
response =>
{
Debug.Log($"GET Request Successful.\nResponse: {response}");
},
error =>
{
Debug.LogError($"GET Request Failed.\nError: {error}");
});

4. Perform a POST Request

Send data to a specified URL using the POST method.

// Example usage of POST request
var postFields = new Dictionary<string, object>
{
{ "title", "foo" },
{ "newUser", false },
{ "userId", 1 }
};
RetroDevRequest.Post(postUrl, postFields, contentType.Json, headers,
response =>
{
Debug.Log($"POST Request Successful.\nResponse: {response}");
},
error =>
{
Debug.LogError($"POST Request Failed.\nError: {error}");
});

5. Perform a PUT Request

Update data at a specified URL using the PUT method.

// Example usage of PUT request
var putData = "{\"id\":1,\"title\":\"foo\",\"body\":\"bar\",\"userId\":1}";
RetroDevRequest.Put(putUrl, putData, headers,
response =>
{
Debug.Log($"PUT Request Successful.\nResponse: {response}");
},
error =>
{
Debug.LogError($"PUT Request Failed.\nError: {error}");
});

6. Perform a DELETE Request

Remove data at a specified URL using the DELETE method.

// Example usage of DELETE request
RetroDevRequest.Delete(deleteUrl, headers,
response =>
{
Debug.Log($"DELETE Request Successful.\nResponse: {response}");
},
error =>
{
Debug.LogError($"DELETE Request Failed.\nError: {error}");
});

Getting Help

Don’t hesitate to reach out if you need help:

  • Email: [email protected]
  • Social: Find me on GitHub, Twitter, or any of the platforms linked in the header

I built these tools to help developers, so please use me as a resource. Questions, bug reports, feature requests—I want to hear all of it.