Quick Start Guide
Master web requests in Unity games with the Eidolon.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 Eidolon.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 headersvar 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 requestEidolonRequest.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 requestvar postFields = new Dictionary<string, object>{ { "title", "foo" }, { "newUser", false }, { "userId", 1 }};
EidolonRequest.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 requestvar putData = "{\"id\":1,\"title\":\"foo\",\"body\":\"bar\",\"userId\":1}";
EidolonRequest.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 requestEidolonRequest.Delete(deleteUrl, headers, response => { Debug.Log($"DELETE Request Successful.\nResponse: {response}"); }, error => { Debug.LogError($"DELETE Request Failed.\nError: {error}"); });
Summary
The Eidolon.Networking
package streamlines HTTP request handling in Unity, making it easier than ever to integrate web-based features into your games. With simple methods for GET, POST, PUT, and DELETE requests, along with customizable headers and error handling, you can quickly set up robust networking functionality. Explore the examples above to get started and enhance your game’s networking capabilities today!