Skip to content

Instantly share code, notes, and snippets.

View AntonZhernosek's full-sized avatar

Anton Zhernosek AntonZhernosek

View GitHub Profile
@AntonZhernosek
AntonZhernosek / UnityWebRequestExtension.cs
Last active August 13, 2023 04:45
UnityWebRequest doesn't support async/await operations natively. With this small extension, it now has an awaiter and can be cancelled via a CancellationToken
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using UnityEngine.Networking;
namespace UnityUtilities.Networking.Extensions
{
public static class UnityWebRequestExtension
{
public static async Task<UnityWebRequest.Result> SendWebRequestAsync(this UnityWebRequest request, CancellationToken ct = default)
@AntonZhernosek
AntonZhernosek / DropdownFieldExtensions.cs
Last active May 23, 2023 12:28
UI Toolkit Dropdown Fields are annoying to deal with because some properties are kept internal to the UnityEditor assembly. Here are 2 simple extensions that allow you to fix it
#if UNITY_EDITOR
using System;
using System.Linq.Expressions;
using System.Reflection;
using UnityEditor;
using UnityEngine.UIElements;
namespace Utilities.Extensions.UIToolkit
{