Skip to content

Instantly share code, notes, and snippets.

Sascha Graeff FlaShG

  • Hamburg
Block or report user

Report or block FlaShG

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@FlaShG
FlaShG / CanvasPositioningExtensions.cs
Last active Nov 14, 2019
A small Unity helper class to convert viewport, screen or world positions to canvas space.
View CanvasPositioningExtensions.cs
using UnityEngine;
/// <summary>
/// Small helper class to convert viewport, screen or world positions to canvas space.
/// Only works with screen space canvases.
/// Usage:
/// objectOnCanvasRectTransform.anchoredPosition = specificCanvas.WorldToCanvasPoint(worldspaceTransform.position);
/// </summary>
public static class CanvasPositioningExtensions
{
@FlaShG
FlaShG / Placr.cs
Last active Oct 27, 2019
Placr increases your level design speed by letting you place objects quickly. https://youtu.be/nm57A2ySfIY
View Placr.cs
using UnityEngine;
using UnityEditor;
/// <summary>
/// Placr increases your level design speed by letting you place objects quickly.
/// Enable Placr in the scene view and select a Prefab or 3D model in your project view.
/// * Left click to place the object.
/// * Right click to de-select the object.
/// * Hold Ctrl to rotate the object with your mouse.
/// * Hold Shift to change the vertical offset. Re-select your asset to reset it.
@FlaShG
FlaShG / GizmosColor.cs
Last active Oct 9, 2019
Temprarily set a color to be used for Gizmos and Handles.
View GizmosColor.cs
using UnityEngine;
using System;
/// <summary>
/// Temprarily set a color to be used for Gizmos.
/// <example>
/// <code>
/// using (new GizmosColor(Color.red))
/// {
@FlaShG
FlaShG / Benchmark.cs
Last active Sep 16, 2019
A C# Benchmark class.
View Benchmark.cs
using System;
using System.Diagnostics;
/// <summary>
/// Simple benchmark class to measure average time consumption of code.
/// </summary>
public static class Benchmark
{
/// <summary>
/// A benchmark's time result.
@FlaShG
FlaShG / UsePropertyNameAttribute.cs
Last active Aug 6, 2019
Fix the display name when serializing property backing fields in Unity.
View UsePropertyNameAttribute.cs
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 / WeakReferenceExtensions.cs
Created Jul 25, 2019
Extension methods to create simple code around working with WeakReferences referencing UnityEngine.Objects.
View WeakReferenceExtensions.cs
using UnityEngine;
/// <summary>
/// Extension methods to create simple code around working with WeakReferences referencing UnityEngine.Objects.
/// </summary>
public static class WeakReferenceExtensions
{
/// <summary>
/// Destroys the referenced object if it still exists.
/// Does nothing if no object is referenced or the referenced object is already destroyed.
@FlaShG
FlaShG / HideFlagsUtility.cs
Created Jul 8, 2019
Shows all GameObjects in the scene with hideFlags, so you can debug them.
View HideFlagsUtility.cs
using UnityEngine;
using UnityEditor;
public static class HideFlagsUtility
{
[MenuItem("Help/Hide Flags/Show All Objects")]
private static void ShowAll()
{
var allGameObjects = Object.FindObjectsOfType<GameObject>();
foreach (var go in allGameObjects)
@FlaShG
FlaShG / EventOrderTest.cs
Last active Apr 28, 2019
Learn about Unity's event order when initializing an object.
View EventOrderTest.cs
using UnityEngine;
public class EventOrderTest : MonoBehaviour
{
private bool firstUpdate = true;
private void Awake()
{
Log("Awake");
}
@FlaShG
FlaShG / ConsoleAccessAttribute.cs
Created Apr 1, 2019
A simple, easy-to-use console for Unity.
View ConsoleAccessAttribute.cs
using System;
[AttributeUsage(AttributeTargets.Method)]
public class ConsoleAccessAttribute : Attribute
{
}
@FlaShG
FlaShG / Invoker.cs
Last active Jan 16, 2019
A replacement for Unity's MonoBehaviour.Invoke and MonoBehaviour.InvokeRepeating, with extra features.
View Invoker.cs
using System;
using System.Collections;
using UnityEngine;
/// <summary>
/// Replaces MonoBehaviour.Invoke and MonoBehaviour.InvokeRepeating
/// with a more sophisticated attempt. Namely: No strings involved.
/// Use like this:
/// StartCoroutine(Invoker.Invoke(MyMethod, 2));
/// </summary>
You can’t perform that action at this time.