Skip to content

Instantly share code, notes, and snippets.

View AlvinC101's full-sized avatar

TSAUR WEN-YU AlvinC101

  • Yuan Ze University
  • 01:30 (UTC +08:00)
View GitHub Profile
@keijiro
keijiro / FpsCapper.cs
Last active May 12, 2025 04:34
FpsCapper - Limits the frame rate of the Unity Editor in Edit Mode
using UnityEditor;
using UnityEngine;
using UnityEngine.LowLevel;
using System.Linq;
using System.Threading;
namespace EditorUtils {
//
// Serializable settings
@adammyhre
adammyhre / UniTaskHelpers.cs
Created August 25, 2024 18:29
A helper class for UniTask that implements a WhenAllSettled method, allowing all tasks to complete and capturing both successful results and exceptions.
using System;
using Cysharp.Threading.Tasks;
/// <summary>
/// Provides helper methods for working with UniTask, including methods to await multiple tasks
/// and capture their results or exceptions.
/// </summary>
public class UniTaskHelpers {
/// <summary>
/// Awaits two UniTasks and returns a tuple containing the results or exceptions for each task.
@adammyhre
adammyhre / AnimationSystem.cs
Last active May 12, 2025 04:31
Simple Wrapper for Unity Playables API
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Animations;
using UnityEngine.Playables;
using MEC; // Uses More Effective Coroutines from the Unity Asset Store
public class AnimationSystem {
PlayableGraph playableGraph;
readonly AnimationMixerPlayable topLevelMixer;
@adammyhre
adammyhre / DStarLite.cs
Last active May 12, 2025 04:33
Implementation of D* Lite Algorithm for Unity
// D* Lite is an incremental heuristic search algorithm that finds the shortest path in a graph
// from a goal node to a start node. It is designed to be efficient in terms of memory and computation
// while updating the graph in real-time.
// Koenig and Likhachev - http://idm-lab.org/bib/abstracts/papers/aaai02b.pdf
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
@adammyhre
adammyhre / AbilitySystem.cs
Last active May 28, 2025 23:41
MVC Ability System
[CreateAssetMenu(fileName = "AbilityData", menuName = "ScriptableObjects/AbilityData", order = 1)]
public class AbilityData : ScriptableObject {
public AnimationClip animationClip;
public int animationHash;
public float duration;
public Sprite icon;
public string fullName;
void OnValidate() {
@unitycoder
unitycoder / AnimatorUtility.cs
Created November 17, 2023 09:13 — forked from hasanbayatme/AnimatorUtility.cs
Unity animator utilities such as checking if the animator has parameter or safely setting the animator parameters.
/**
MIT License
Copyright (c) 2023 Bayat Games
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@forestrf
forestrf / Selectable.cs
Last active May 12, 2025 04:28
Improved UI navigation on Selectable.cs
// Improved navigation code
using System;
using System.Collections.Generic;
using UnityEngine.Serialization;
using UnityEngine.EventSystems;
namespace UnityEngine.UI
{
[AddComponentMenu("UI/Selectable", 35)]
[ExecuteAlways]
using System;
using UnityEngine;
using TMPro;
/// <summary>
/// A generic 2D grid implementation that can be used in both 2D and 3D.
/// The grid stores values of a specified type and provides methods for accessing and modifying
/// these values based on grid coordinates or world coordinates. The grid can be displayed
/// either vertically (X-Y plane) or horizontally (X-Z plane) using a CoordinateConverter.
/// </summary>
@adammyhre
adammyhre / InspectorLock.cs
Last active May 12, 2025 04:28
Lock Inspector Icon and Transform Constrain Proportion Icon in Unity
using System.Reflection;
using UnityEditor;
using UnityEngine;
/// <summary>
/// Toggles the Inspector lock state and the Constrain Proportions lock state.
/// </summary>
public static class LockInspector {
static readonly MethodInfo flipLocked;
static readonly PropertyInfo constrainProportions;
@ScottJDaley
ScottJDaley / Outline.shader
Last active May 12, 2025 04:36
Wide Outlines Renderer Feature for URP and ECS/DOTS/Hybrid Renderer
// Original shader by @bgolus, modified slightly by @alexanderameye for URP, modified slightly more
// by @gravitonpunch for ECS/DOTS/HybridRenderer.
// https://twitter.com/bgolus
// https://medium.com/@bgolus/the-quest-for-very-wide-outlines-ba82ed442cd9
// https://alexanderameye.github.io/
// https://twitter.com/alexanderameye/status/1332286868222775298
Shader "Hidden/Outline"
{
Properties