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; } |
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 | |
{ |
View CoroutineWorker.cs
using UnityEngine; | |
using System.Collections; | |
public static class CoroutineWorker | |
{ | |
private class Worker : MonoBehaviour { } | |
private static Worker worker; | |
[RuntimeInitializeOnLoadMethod] |
View FloatRange.cs
using UnityEngine; | |
[System.Serializable] | |
public struct FloatRange | |
{ | |
public float min; | |
public float max; | |
public float range { get { return Mathf.Abs(max - min); } } | |
public FloatRange(float min, float max) |
View PathAttribute.cs
using UnityEngine; | |
public class PathAttribute : PropertyAttribute | |
{ | |
} |
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> |
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) | |
{ |
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() |
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. |
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 | |
{ |