Skip to content

Instantly share code, notes, and snippets.

View rtlsilva's full-sized avatar

Ricardo Silva rtlsilva

  • Leiria, Portugal
View GitHub Profile
@rtlsilva
rtlsilva / 00_ISequencer.cs
Created November 29, 2023 23:11
A reactive sequencing library for coordinating time-based operations
using System;
using UniRx;
namespace MyNamespace.Sequencing {
/// <summary>
/// Defines functionality for providing observable sequencing capabilities.
/// </summary>
public interface ISequencer : IObservable<Unit> {
/// <summary>
/// Adds the given <paramref name="observable"/> to this <see cref="ISequencer"/>.
@rtlsilva
rtlsilva / 00_ARFoundationController.cs
Last active November 29, 2023 22:36
Components and extensions that aid in working with AR Foundation using reactive programming
using System;
using UniRx;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.XR.ARFoundation;
using MyNamespace.Utils;
using MyNamespace.Extensions;
namespace MyNamespace.AR
{
@rtlsilva
rtlsilva / GameObjectSnapshotRenderer.cs
Created November 29, 2023 22:09
A utility class that takes snapshots of GameObjects by rendering them to textures
using System;
using System.Linq;
using UniRx;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UI;
using MyNamespace.Extensions;
namespace MyNamespace.Utils
{
import 'package:dio/dio.dart';
import 'package:my_api/api.dart';
/// Creates instance of [Dio] to be used in the remote layer of the app.
Dio createDio(BaseOptions baseConfiguration) {
var dio = Dio(baseConfiguration);
dio.interceptors.addAll([
// interceptor to retry failed requests
// interceptor to add bearer token to requests
// interceptor to refresh access tokens
@rtlsilva
rtlsilva / ResourcePathAttribute.cs
Created June 7, 2019 15:18
Store a path to a resource instead of referencing the object
using UnityEngine;
using System;
public class ResourcePathAttribute : PropertyAttribute {
public Type resourceType;
public ResourcePathAttribute(Type t) {
this.resourceType = t;
}
}
@rtlsilva
rtlsilva / TimeKeeper.cs
Created May 3, 2016 04:51
Unity3D scripts that keep track of multiple independent time layers, each with its own time scale and all updated from a single timer. This allows, for example, to simultaneously have multiple entities operating at a sped up/slowed down rate and being frozen in time by simply changing their TimeLayer in the Inspector.
using System.Collections;
using System.Diagnostics;
using UnityEngine;
public enum TimeLayer {
//Unity's time
GameTime,
//Custom time layer for UI
MenuTime,
//Unity's unscaled time