Skip to content

Instantly share code, notes, and snippets.

View AldeRoberge's full-sized avatar
💛
.

Alexandre D. Roberge AldeRoberge

💛
.
View GitHub Profile
@AldeRoberge
AldeRoberge / TeleportKinematicCharacterController.cs
Created March 31, 2024 15:53
Allows to teleport a Kinematic Character Controller
// Get the ExampleCharacterController
if (_kccMotor.CharacterController is not ExampleCharacterController exampleCharacterController)
{
Debug.LogError("ExampleCharacterController is null");
return;
}
// Disable
exampleCharacterController.enabled = false;
@AldeRoberge
AldeRoberge / SpriteImageProcessor.cs
Created March 6, 2024 22:52
Converts a sprite (16x16 pixels) into a RotMG-like sprite (with outline and shadow)
using System;
using System.Diagnostics;
using SkiaSharp;
namespace AGES.Utils.Runtime.SpriteImageProcessor
{
public class SpriteImageProcessor
{
public SpriteImageProcessor()
{
@AldeRoberge
AldeRoberge / ProjectWideSearch.ps1
Created February 15, 2024 19:15
Find broken managed references in Unity caused by [SerializeReference], projectwide search for the GUIDs
# The provided script is designed to be useful for identifying broken references caused by the [SerializeReference] attribute in Unity. In Unity, when creating a prefab for a script in a scene, old values may persist, potentially disrupting the SerializeReference mechanism and leading to errors during scene opening or building. The script helps locate and identify broken .asset (YAML) references in the Unity project.
param (
[string]$searchDirectory = "C:\Users\Alde\Documents\GitHub\Wikwemot-AR\Wikwemot-AR\Assets",
[string]$searchString = "6945820829875175427"
)
function Search-FilesForString {
param (
[string]$directory,
@AldeRoberge
AldeRoberge / UnityConsoleRedirect.cs
Created January 24, 2024 13:17
Redirects console output (Console.WriteLine) to Unity (Debug.Log)
using System;
using System.IO;
using System.Text;
using UnityEngine;
namespace AGES.Utils.Runtime.Logging
{
/// <summary>
/// Redirects console output (Console.WriteLine) to Unity (Debug.Log)
/// </summary>
@AldeRoberge
AldeRoberge / ChatInputHistory.cs
Created January 8, 2024 04:31
ChatInputHistory using player prefs for Unity, not perfect but does the job
using System.Collections.Generic;
using UnityEngine;
namespace AGES.Networking.AGES.Networking.Runtime.Client.Scripts.UI.Chat
{
public class ChatInputHistory : MonoBehaviour
{
// Keeps a record of previous player chat input and allows the player to scroll through it
private readonly List<string> chatHistory = new();
@AldeRoberge
AldeRoberge / EditorMenuCleanup.cs
Created November 23, 2023 15:47
Reduce cluter in Unity Editor Create Menu
using UnityEngine;
namespace AGES.Tools.Editor.EditorMenuCleanUp
{
public static class EditorMenuCleanup
{
[UnityEditor.InitializeOnLoadMethod]
private static void MenuCleanUp()
{
UnityEditor.EditorApplication.delayCall += RemoveMenuItems;
@AldeRoberge
AldeRoberge / ReflectionUtils.cs
Created August 25, 2023 05:01
C# ReflectionUtils to get InheritsOrImplements certain class
public static class ReflectionUtils
{
public static bool InheritsOrImplements(this Type child, Type parent)
{
parent = ResolveGenericTypeDefinition(parent);
var currentChild = child.IsGenericType
? child.GetGenericTypeDefinition()
: child;
@AldeRoberge
AldeRoberge / Program.cs
Created July 29, 2023 04:22
RotMG-inspired sprite upscaler. Converts 16x16 sprites to 80x80 with border and drop shadow.
using System;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using SkiaSharp;
namespace AGES_Sprite_Processor
{
internal class Program
{
@AldeRoberge
AldeRoberge / UnityNLogTarget.cs
Created May 24, 2023 02:55
Route NLOG to the Unity Engine .Log console
namespace Scripts.Utils.Logging
{
/// <summary>
/// Logs NLog to Unity 'Debug' function.
/// Useful to read output of external dlls.
/// </summary>
public class UnityNLogTarget : TargetWithLayout
{
public static void Init()
{
@AldeRoberge
AldeRoberge / HalfSphere.mesh
Created May 16, 2023 02:12
Half Sphere / Dome (.Mesh file) for Unity
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!43 &4300000
Mesh:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: HalfSphere
serializedVersion: 10