Skip to content

Instantly share code, notes, and snippets.

Sascha Graeff FlaShG

  • Hamburg
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 / 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 / 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]
@FlaShG
FlaShG / CoroutinePoolThread.cs
Last active Oct 28, 2018
Small classes that allow for comfortably executing a single thread or a threadpool task in a coroutine.
View CoroutinePoolThread.cs
using UnityEngine;
using System;
using System.Threading;
/// <summary>
/// Orders the Threadpool to perform an action and waits until it's done.
/// Use for short actions that maybe are performed more often.
/// </summary>
public class CoroutinePoolThread : CustomYieldInstruction
{
@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
{
}
You can’t perform that action at this time.