Skip to content

Instantly share code, notes, and snippets.

@thsbrown
thsbrown / AndroidRuntimeAsyncPermissionService.cs
Created October 24, 2024 18:39
Converts unity android runtime permission API to async
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Android;
//see https://docs.unity3d.com/ScriptReference/Android.Permission.html
//see https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Android.PermissionCallbacks.html
public static class AndroidRuntimeAsyncPermissionService
{
public static async Task<PermissionResult> RequestPermissionAsync(string permission)
{
@thsbrown
thsbrown / ErrorableInput.cs
Last active July 12, 2024 08:47
Optimized Unity TMP_InputField for Steam Deck keyboard!
using System;
using DG.Tweening;
using Sirenix.OdinInspector;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// An input that allows for easy error reporting alongside it
/// </summary>
@thsbrown
thsbrown / ErrorableInput.cs
Last active November 16, 2023 01:48
A relatively hacky way to work around TMP_InputField
using System;
using DG.Tweening;
using Sirenix.OdinInspector;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// An input that allows for easy error reporting alongside it
/// </summary>
@thsbrown
thsbrown / DOTweenBehavior.cs
Created August 17, 2022 19:47
DOTween + Unity Timeline Example
public class DOTweenBehavior : PlayableBehaviour
{
public bool tweenPosition;
public Vector3 targetPosition;
public bool tweenRotation;
public Vector3 targetRotation;
public Ease ease;
private bool firstFrameProcessed;
private Sequence sequence;
@thsbrown
thsbrown / ErrorHandlingExample.cs
Created April 29, 2022 18:43
Azure Functions PlayFab Error Handling
public static class ErrorHandlingExample
{
[FunctionName("ErrorHandlingExample")]
public static async Task<dynamic> RunAsync(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req, ILogger log)
{
var errorOccurred = true;
if(errorOccurred)
{
return new PlayFabErrorObjectResult(1000, "An error has occurred");
@thsbrown
thsbrown / ETCDpadButtonInvoker.cs
Created April 29, 2020 16:00
ETCDpadButtonInvoker
using Sirenix.OdinInspector;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
/// <summary>
/// Allows invoking of <see cref="ETCDPad"/> buttons script side.
/// </summary>
public class ETCDpadButtonInvoker : MonoBehaviour {
/// <summary>
@thsbrown
thsbrown / P12Generator4AppleApps
Created March 31, 2020 16:23
Batch file to help easily create all the files needed to get apple app/game up and running without using a mac
echo off
cd c:\
cd c:\OpenSSL-Win32\bin
echo.
echo.
echo -----------------App P12 File Generator---------------
echo.
echo This batch file was made to help you easily create all
echo the files you need to get your apple app/game up and