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 / 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 / CorouTweenTest.cs
Last active Sep 18, 2018
Very simple Tweens for Unity using Coroutines.
View CorouTweenTest.cs
using UnityEngine;
public class CorouTweenTest : MonoBehaviour
{
[SerializeField]
private Vector3 targetPosition;
[SerializeField]
private float duration = 1;
private void Start()
@FlaShG
FlaShG / ClassicEditorArrowMovement.cs
Last active Jul 18, 2018
A Unity editor script for enabling pre-2018.x scene view camera behaviour for arrow keys.
View ClassicEditorArrowMovement.cs
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
/// <summary>
/// Re-enables pre-2018.x scene view camera behaviour for arrow keys.
/// Allows the user to move the scene view camera on a horizontal plane.
/// </summary>
public static class ClassicEditorArrowMovement
{
@FlaShG
FlaShG / StateMachine.cs
Last active Jul 17, 2018
A simple state machine class for Unity. Use it to run regular methods or coroutines as states.
View StateMachine.cs
using UnityEngine;
using System;
using System.Collections;
/// <summary>
/// A simple state machine class. Use it to run regular methods or coroutines as states.
/// Steps to use:
/// 1. Define a private field for the StateMachine object.
/// private StateMachine stateMachine;
/// 2. Initialize the object in Awake. Pass the MonoBehaviour object to the constructor.
@FlaShG
FlaShG / ParticleManipulator.cs
Last active Jul 4, 2018
A superclass for classes that manipulate particles in Update.
View ParticleManipulator.cs
using UnityEngine;
/// <summary>
/// Create a subclass of this class to manipulate particles in Update any way you see fit.
/// </summary>
[RequireComponent(typeof(ParticleSystem))]
[ExecuteInEditMode]
public abstract class ParticleManipulator : MonoBehaviour
{
new protected ParticleSystem particleSystem { get; private set; }
@FlaShG
FlaShG / CanvasPositioningExtensions.cs
Last active Aug 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
{
You can’t perform that action at this time.