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 / FBXAxesFixer.cs
Last active Aug 29, 2015
This AssetPostprocessor switches the Y and Z axes of imported FBX files (and everything converted to FBX from Unity).
View FBXAxesFixer.cs
using UnityEngine;
using UnityEditor;
public class FBXAxesFixer : AssetPostprocessor
{
void OnPostprocessModel(GameObject g)
{
if(assetImporter.ToString() == " (UnityEngine.FBXImporter)")
{
FixFBXImport(g.transform, 0);
@FlaShG
FlaShG / MyStaticCode.cs
Last active Apr 12, 2018
Execute any code based on Unity events without having to drag a component into a scene.
View MyStaticCode.cs
using UnityEngine;
/// <summary>
/// This template allows to define code that runs independently of any GameObjects or Components created in the editor, even though using Unity events.
/// It can be used for any Scene-independent code, including coroutines, without having to manually add a component to a scene.
/// </summary>
public static class MyStaticCode
{
[RuntimeInitializeOnLoadMethod]
private static void Initialize()
@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 / MinMaxFloat.cs
Last active Jul 4, 2018
A small struct representing a range from min to max.
View MinMaxFloat.cs
using UnityEngine;
[System.Serializable]
public struct MinMaxFloat
{
public float min;
public float max;
public float range { get { return Mathf.Abs(max - min); } }
public MinMaxFloat(float min, float max)
@FlaShG
FlaShG / PathAttribute.cs
Last active Jul 4, 2018
Allows setting a string in the Unity Editor by dragging a file or folder from outside the editor.
View PathAttribute.cs
using UnityEngine;
public class PathAttribute : PropertyAttribute
{
}
@FlaShG
FlaShG / SetScriptExecutionOrder.cs
Last active Jul 4, 2018
Add this to a MonoBehaviour to set its Script Execution Order without access to the editor.
View SetScriptExecutionOrder.cs
#if UNITY_EDITOR
private const int executionOrder = -1000;
[UnityEditor.InitializeOnLoadMethod]
private static void SetScriptOrder()
{
var go = new GameObject("Temp");
var monoScript = UnityEditor.MonoScript.FromMonoBehaviour(go.AddComponent<NAME_OF_THIS_MONOBEHAVIOUR>());
if (UnityEditor.MonoImporter.GetExecutionOrder(monoScript) != executionOrder)
{
@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 / 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 / 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 / CoroutineWorker.cs
Last active Sep 25, 2018
Based on MyStaticCode.cs, a class that allows anything to run coroutines from anywhere.
View CoroutineWorker.cs
using UnityEngine;
using System.Collections;
public static class CoroutineWorker
{
private class Worker : MonoBehaviour { }
private static Worker worker;
[RuntimeInitializeOnLoadMethod]
You can’t perform that action at this time.