Skip to content

Instantly share code, notes, and snippets.

@trs-game-tech
trs-game-tech / DebugTriggerButton.cs
Last active July 8, 2025 12:18
【Unity】連続タップでデバッグメニューを開くボタン
// Released under The Unlicense: https://unlicense.org/
// Source: https://gist.github.com/trs-game-tech/3f3e877c4f98df8a7514d8956ab7f0f4
// Dependency Source: https://gist.github.com/trs-game-tech/ed14c02a70027df7043272c632a0e32f
using UnityEngine;
using UnityEngine.Events;
public sealed class DebugTriggerButton : MonoBehaviour
{
[SerializeField] private int _activateThreshold = 3;
@trs-game-tech
trs-game-tech / GhostButton.cs
Last active July 8, 2025 12:17
【Unity】背面の入力を邪魔しないボタンコンポーネント
// Released under The Unlicense: https://unlicense.org/
// Source: https://gist.github.com/trs-game-tech/ed14c02a70027df7043272c632a0e32f
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
public class GhostButton : MonoBehaviour, ICanvasRaycastFilter
{
@trs-game-tech
trs-game-tech / SerializedBooleanDispatcher.cs
Last active June 25, 2025 15:00
【Unity/uGUI】UIのON/OFFなどを柔軟にコントロールできるシリアライズデータ
// Released under The Unlicense: https://unlicense.org/
// Source: https://gist.github.com/trs-game-tech/5a1798bcff17360d714819731d83e131
using System;
using UnityEngine;
using UnityEngine.Events;
[Serializable]
public sealed class SerializedBooleanDispatcher
{
@trs-game-tech
trs-game-tech / ComponentMenuItem.RevertComponentAllOverrides.cs
Last active June 25, 2025 12:11
【Unity】Component内のoverrideをすべてRevertするエディタ拡張
// Released under The Unlicense: https://unlicense.org/
// Source: https://gist.github.com/trs-game-tech/fa6f5b11f162bf04bc47f5788e34b504
#if UNITY_EDITOR
using UnityEngine;
namespace UnityEditor
{
public static partial class ComponentMenuItems
{
@trs-game-tech
trs-game-tech / IDisposable.DisposeNextFrame.cs
Last active June 20, 2025 12:44
【UniTask】次のフレームまでDisposeを遅延させる拡張関数 DisposeNextFrame
// Released under The Unlicense: https://unlicense.org/
// Source: https://gist.github.com/trs-game-tech/2cee6d912e0f3ac1a9d3d36678763f8b
using System;
using Cysharp.Threading.Tasks;
public static partial class DisposableExtensions
{
public static void DisposeNextFrame(this IDisposable disposable)
{
@trs-game-tech
trs-game-tech / BooleanDispatcherComponent.cs
Last active June 25, 2025 13:44
【Unity/uGUI】UIのON/OFFなどを柔軟にコントロールできるコンポーネント
// Released under The Unlicense: https://unlicense.org/
// Source: https://gist.github.com/trs-game-tech/cc06e39353504800e7230f762a92cf05
using UnityEngine;
using UnityEngine.Events;
public sealed class BooleanDispatcherComponent : MonoBehaviour
{
[SerializeField] private UnityEvent<bool> _onReceive;
[SerializeField] private UnityEvent<bool> _onReceiveInvert;
@trs-game-tech
trs-game-tech / UniTaskCompletionSource.WithCancellation.cs
Last active June 20, 2025 12:45
【UniTask】UniTaskCompletionSourceとCancellationTokenを紐つける拡張関数
// Released under The Unlicense: https://unlicense.org/
// Source: https://gist.github.com/trs-game-tech/1308737fa567b28b774b227ec7decfc7
using System.Threading;
using Cysharp.Threading.Tasks;
public static partial class UniTaskCompletionSourceExtensions
{
public static UniTask WithCancellation(this UniTaskCompletionSource source, CancellationToken cancellationToken)
{