Skip to content

Instantly share code, notes, and snippets.

View RyanGarber's full-sized avatar

Ryan RyanGarber

View GitHub Profile
@RyanGarber
RyanGarber / FishyRealtimeV2.cs
Created September 6, 2023 12:42
Improved Photon Realtime Transport for FishNet
public class NetworkTransport : Transport, IOnEventCallback, IMatchmakingCallbacks, IInRoomCallbacks
{
public LoadBalancingClient Photon = new();
public override void Initialize(NetworkManager networkManager, int transportIndex)
{
base.Initialize(networkManager, transportIndex);
Photon.AddCallbackTarget(this);
}
@RyanGarber
RyanGarber / EOSExtensions.cs
Created September 2, 2023 00:56
C# Async/Await for Epic Online Services
public static class EOSExtensions
{
public static readonly uint ChunkSize = 4096;
#region Auth
public static async Task<Auth.LoginCallbackInfo> StartPersistentLogin(this EOSManager.EOSSingleton @this)
{
Auth.LoginCallbackInfo? result = null;
@this.StartPersistentLogin(r => result = r);
while (!result.HasValue) await Task.Yield();
@RyanGarber
RyanGarber / UIBehaviour.cs
Last active August 2, 2023 06:50
jQuery-style queries for Unity's UI Toolkit
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEngine.UIElements;
public class UIBehaviour : MonoBehaviour
{
public List<VisualElement> Find(string query, bool one = false)
@RyanGarber
RyanGarber / SpatialAudioListener.cs
Created July 24, 2023 06:14
[FMOD + Steam Audio + Unity] Changing cameras, events, and parameters at runtime. Requires changing some members to public.
using UnityEngine;
using SteamAudio;
public class SpatialAudioListener : MonoBehaviour
{
private SteamAudioListener _steamAudioListener;
private System.Action _onSteamAudioListenerReady;
private bool _isSteamAudioListenerReady = false;
@RyanGarber
RyanGarber / InverseKinematics.cs
Last active July 22, 2023 17:43
Inverse kinematics for holding an object inside Unity
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Inverse kinematics. Attaches hands to a weapon and rotates a head in the direction it's looking.
/// </summary>
[DefaultExecutionOrder(1000)]
public class InverseKinematics : MonoBehaviour
{
@RyanGarber
RyanGarber / GenericTable.cs
Last active July 22, 2023 17:44
A weird workaround I created when I was 14 years old, kept here only for sentimental value
using System.Collections.Generic;
public class GenericTable<T, U> {
private List<GenericTableEntry> Table = new List<GenericTableEntry>();
public void Add(T Key, U Value) {
Table.Add(new GenericTableEntry(Key, Value));
}
public GenericTableEntry[] GetAll() {