Skip to content

Instantly share code, notes, and snippets.

View AldeRoberge's full-sized avatar
💛
.

Alexandre D. Roberge AldeRoberge

💛
.
View GitHub Profile
@AldeRoberge
AldeRoberge / android-google-play.yaml
Created June 20, 2024 05:27
GameCI Build GitHub Actions for Android (fails after 50 minutes)
name: Build Game for Android and publish to Google Play
on:
push:
branches:
- main
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
@AldeRoberge
AldeRoberge / AddBackground.cs
Created June 18, 2024 15:29
Adds a (white) background to png images and export them to jpeg.
using SkiaSharp;
namespace AGXSpriteProcessor
{
// Loads all images in a directory, adds a white background, and saves them to a new directory as .jpeg
public static class AddBackground
{
private const string InputDirectory = @"C:\Users\Alde\Desktop\Wik";
private const string OutputDirectory = @"C:\Users\Alde\Desktop\Wik\Output";
@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
{