Skip to content

Instantly share code, notes, and snippets.

View FlaShG's full-sized avatar

Sascha Graeff FlaShG

View GitHub Profile
@FlaShG
FlaShG / UsePropertyNameAttribute.cs
Last active January 20, 2023 07:18
Fix the display name when serializing property backing fields in Unity.
using UnityEngine;
/// <summary>
/// Use this attribute in combination with a [SerializeField] attribute on top of a property to display the property name. Example:
/// [field: SerializeField, UsePropertyName]
/// public int number { get; private set; }
/// </summary>
public class UsePropertyNameAttribute : PropertyAttribute
{
@FlaShG
FlaShG / GizmosColor.cs
Last active August 19, 2021 18:52
Temprarily set a color to be used for Gizmos and Handles.
using UnityEngine;
using System;
/// <summary>
/// Temporarily set a color to be used for Gizmos.
/// <example>
/// <code>
/// using (new GizmosColor(Color.red))
/// {
@FlaShG
FlaShG / FavoritesWindow.cs
Last active March 14, 2024 04:53
A Unity EditorWindow to pin objects to for quick selection.
using UnityEngine;
using UnityEditor;
using UnityEditorInternal;
using System.Collections.Generic;
/// <summary>
/// An editor window that lets you store assets and GameObjects in it for quickly finding them again.
/// </summary>
public class FavoritesWindow : EditorWindow, IHasCustomMenu
{
@FlaShG
FlaShG / RuntimeSceneReference.cs
Created May 7, 2023 12:47
A serializable struct for referencing and, at runtime, handle scenes.
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
using UnityEngine.SceneManagement;
[System.Serializable]
public struct RuntimeSceneReference : ISerializationCallbackReceiver
{
@FlaShG
FlaShG / CoroutineEvent.cs
Last active August 17, 2023 19:41
An event class for Unity that can run coroutines.
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// An event that can run coroutines.
/// Invoking it returns an IEnumerator that can be waited for in another coroutine.
/// The Invocation waits until all registered coroutines are finished.
/// </summary>