Skip to content

Instantly share code, notes, and snippets.

View noisecrime's full-sized avatar

NoiseCrime noisecrime

View GitHub Profile
@noisecrime
noisecrime / ScriptExecutionAssignment.cs
Created November 10, 2016 19:47
Editor class that will automatically set the scriptExecutionOrder based on using a ScriptExecutionAttribute.
// ScriptExecutionAssignment
// NoiseCrime
// 11.10.2016
// 05.06.2016
//
//
// Editor class that will automatically set the scriptExecutionOrder based on using a ScriptExecutionAttribute.
// See ScriptExecutionAttribute.cs Gist!
// The class is called automatically everytime Unity recompiles the project - see [InitializeOnLoad]
//
@noisecrime
noisecrime / ScriptExecutionAttribute.cs
Created November 10, 2016 19:48
Support Attribute class that works with the editor script 'ScriptExecutionAssignment' to automatically populate the ScriptExecutionOrder.
// ScriptExecutionAttribute
// NoiseCrime
// 10.11.2016
// 05.06.2016
//
// Support Attribute class that works with the editor script 'ScriptExecutionAssignment' to automatically populate the ScriptExecutionOrder.
// Simply add [ScriptExecutionAttribute( value )] prior to your class declaration, where value indicates the script order you want ( -9999 to +9999 )
// This script must NOT be placed in an Editor Folder.
cbuffer CB
{
matrix View;
matrix Projection;
matrix ViewProjection;
float4 FrustumPlanes[6]; // view-frustum planes in world space (normals face out)
float2 ViewportSize; // Viewport Width and Height in pixels
float4 vTexels;
vTexels.x = LastMip.Load( nCoords );
vTexels.y = LastMip.Load( nCoords, uint2(1,0) );
vTexels.z = LastMip.Load( nCoords, uint2(0,1) );
vTexels.w = LastMip.Load( nCoords, uint2(1,1) );
float fMaxDepth = max( max( vTexels.x, vTexels.y ), max( vTexels.z, vTexels.w ) );
@noisecrime
noisecrime / StopWatchProfiler
Created September 10, 2017 10:31
StopWatchProfiler
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
#if UNITY_5_5_OR_NEWER
using Profiler = UnityEngine.Profiling.Profiler;
#endif
public class StopWatchProfiler : MonoBehaviour
@noisecrime
noisecrime / WebcamProcessingTesting.cs
Created May 1, 2018 06:58
Optimizing step for WebProcessing
using UnityEngine;
using Unity.Jobs;
using Unity.Collections;
using Unity.Mathematics;
public class WebcamProcessingTesting : MonoBehaviour
{
[SerializeField]
[Tooltip("Which webcam to use")]
int m_WebcamIndex;
@noisecrime
noisecrime / UpdateInspectorBehaviour.cs
Created September 13, 2018 11:36
Example of how to expose a field from a class reference and have it update the inspector at an 'appropriate' framerate
using UnityEngine;
public class UpdateInspectorBehaviour : MonoBehaviour
{
public class CustomValueClass
{
public int _MyUpdatingValue;
}
public CustomValueClass _CustomValueClass;
@noisecrime
noisecrime / ResourceChecker.cs
Last active October 11, 2021 14:00
Unity: Quick update to original 'Unity-Resource-Checker' to use native Unity methods for obtaining the memory size of textures.
// Resource Checker
// (c) 2012 Simon Oliver / HandCircus / hello@handcircus.com
// (c) 2015 Brice Clocher / Mangatome / hello@mangatome.net
// Public domain, do with whatever you like, commercial or not
// This comes with no warranty, use at your own risk!
// https://github.com/handcircus/Unity-Resource-Checker
// (c) 2019 NoiseCrime
// Quick update to use native Unity methods to obtain the size of textures.
// Looking through the code much has changed since this class was first created
// as such it requires a full rewrite to fix various issues and robustly deal
@noisecrime
noisecrime / Unity Assembly Definition Debugger.cs
Created January 19, 2020 14:02 — forked from karljj1/Unity Assembly Definition Debugger.cs
Find out what assemblies are being built and how long each takes.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using UnityEditor;
using UnityEditor.Compilation;
using UnityEngine;
namespace NoiseCrimeStudios.Editor.Settings
{
@noisecrime
noisecrime / InternalScreenShotting.cs
Last active March 19, 2021 03:14
Exposes the native Unity 'ScreenShotting' methods to Unity Menu & Shortcut keys.
using UnityEditor;
using UnityEngine;
namespace NoiseCrimeStudios.Editor.Internal
{
/// <summary>
/// Exposes the native Unity 'ScreenShotting' methods to Unity Menu & Shortcut keys.
/// </summary>
/// <remarks>
/// Once imported you can find the menu in either Window/Analysis/Screenshot or Window/Internal/Screenshot.