Skip to content

Instantly share code, notes, and snippets.

View CRodriguez25's full-sized avatar

Carlos Rodriguez CRodriguez25

View GitHub Profile
@CRodriguez25
CRodriguez25 / EmbedBuilderExtensions.cs
Last active December 15, 2020 01:19
A simple extension method for rendering progress bars with Discord.Net EmbedBuilders
public static class EmbedBuilderExtensions
{
public static EmbedBuilder AddProgressBar(
this EmbedBuilder embedBuilder,
string title,
float value,
float min,
float max,
bool inline = false,
string filledEmoji = ":green_square:",
@CRodriguez25
CRodriguez25 / CopyWith.cs
Created April 28, 2020 17:54
A couple of useful Vector extension methods for creating Vectors based on other vectors
public static class ExtensionMethods
{
public static Vector2 CopyWith(this Vector2 vector, float? x = null, float? y = null)
{
return new Vector2(x ?? vector.x, y ?? vector.y);
}
public static Vector3 CopyWith(this Vector3 vector, float? x = null, float? y = null, float? z = null)
{
return new Vector3(x ?? vector.x, y ?? vector.y, z ?? vector.z);
@CRodriguez25
CRodriguez25 / UIPanelToggler.cs
Last active April 30, 2020 23:47
Add this script to any UI Element you want to dynamically show or hide (with animation), and set "Open" to true or false show/hide dynamically. Works with ScreenSpace.Overlay and ScreenSpace.Camera UI Canvases
using UnityEngine;
public enum ToggleType
{
Vertical,
Horizontal
}
public class UIPanelToggler: MonoBehaviour
{
@CRodriguez25
CRodriguez25 / GameEventMessageBus.cs
Created April 25, 2020 21:32
Unity Game Event Message Bus
using System;
using System.Collections.Generic;
public class GameEventMessageBus
{
private static Dictionary<Type, List<Action<object>>> _subscriberDict = new Dictionary<Type, List<Action<object>>>();
public static void Subscribe<T>(Action<T> handler)
{
var type = typeof(T);