Skip to content

Instantly share code, notes, and snippets.

View StagPoint's full-sized avatar

StagPoint Software StagPoint

  • StagPoint Software
  • Seattle, WA
View GitHub Profile
// Used to generate Texture Array asset
// Menu button is available in GameObject > Create Texture Array
// See CHANGEME in the file
using UnityEngine;
using UnityEditor;
public class TextureArray : MonoBehaviour {
[MenuItem("GameObject/Create Texture Array")]
static void Create()
@augustoproiete
augustoproiete / ReadingPortableExecutable_PE_header.cs
Created December 6, 2016 04:03
Reading the Portable Executable (PE) header in C#
// Credits: John Stewien
// From: http://code.cheesydesign.com/?p=572
/*
Reading the Portable Executable (PE) header in C#
My job consists of writing fully custom applications for groups of people. The time pressure of these projects is quite high, so generally people start using the application while I’m still writing it, which means I write it modularly and add features as I go along. I also fix bugs as they are discovered. My clients are 2 tiered where expert users get a new build first, they test if for a while, and if they think it’s acceptable they then pass it on to others.
This method of distribution is quite ad-hoc so when a client rings me up and asks me to view their screen to look at something, it’s useful to know what build they are running. To facillitate this I print the link date in the main Window Title so I instantly have an idea about how old the version is that I am looking at. This date is calculated at run time. To do this requires reading in the Portable Executable (PE) header from th
@sinbad
sinbad / MeshRendererSortingEditor.cs
Last active January 28, 2025 17:11
Expose sorting layer in MeshRenderer inspector, for rendering on top of sprites
using UnityEngine;
using UnityEditor;
using System.Linq;
/// This just exposes the Sorting Layer / Order in MeshRenderer since it's there
/// but not displayed in the inspector. Getting MeshRenderer to render in front
/// of a SpriteRenderer is pretty hard without this.
[CustomEditor(typeof(MeshRenderer))]
public class MeshRendererSortingEditor : Editor
{
@tomkail
tomkail / ExtendedScriptableObjectDrawer.cs
Last active April 28, 2025 07:37
Displays the fields of a ScriptableObject in the inspector
// Developed by Tom Kail at Inkle
// Released under the MIT Licence as held at https://opensource.org/licenses/MIT
// Must be placed within a folder named "Editor"
using System;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
@GlaireDaggers
GlaireDaggers / CelestialBody.cs
Created May 31, 2017 19:05
Celestial Body Class
/// <summary>
/// A celestial body that exists in a solar system
/// See http://www.stjarnhimlen.se/comp/ppcomp.html
/// </summary>
public abstract class CelestialBody
{
/// <summary>
/// The day number
/// </summary>
public static float d;
@TiliSleepStealer
TiliSleepStealer / DoomGlow.cs
Created June 13, 2017 21:45
Doom glow - fake volumetric light glow effect in Unity by Tili_us
// This file is in the public domain. Where
// a public domain declaration is not recognized, you are granted
// a license to freely use, modify, and redistribute this file in
// any way you choose.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Unity remake of a fake volumetric light glow effect
@dady8889
dady8889 / Generic.xaml
Last active July 25, 2023 06:42
C# WPF - Windows 10 Button Style
<Style
x:Key="ButtonFocusVisual">
<Setter
Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2" />
</ControlTemplate>
</Setter.Value>
</Setter>
@cancinconn
cancinconn / Pearlescent.shader
Last active March 18, 2025 08:35
An attempt at a basic pearlescent shader for Unity.
Shader "Custom/Pearlescent" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_ColorDirect("Indirect Color", Color) = (1,1,1,1)
//_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_Iterations("Iridescence Function Iterations (Power)", Range(0,20)) = 5
}
SubShader {
@Phyllostachys
Phyllostachys / Pearlescent.shader
Created July 15, 2017 05:05 — forked from cancinconn/Pearlescent.shader
An attempt at a basic pearlescent shader for Unity.
Shader "Custom/Pearlescent" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_ColorDirect("Indirect Color", Color) = (1,1,1,1)
_Iterations("Iridescence Function Iterations (Power)", Range(0,10)) = 5
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
@mvacha
mvacha / ThresholdingAlgo.cs
Created July 21, 2017 18:01
C# implementation of Thresholding algorithm used for peek (and through) detection from https://stackoverflow.com/questions/22583391/peak-signal-detection-in-realtime-timeseries-data/22771985
/// <summary>
/// Algo from: https://stackoverflow.com/questions/22583391/peak-signal-detection-in-realtime-timeseries-data/22771985
/// </summary>
public static (IList<double> avg, IList<double> sd, IList<int> detected)
ThresholdingAlgo(this IList<double> values, int windowSize, double threshold, double influence){
//number in constructor represent capacity, not size
var avg = new List<double>(values.Count);
var mad = new List<double>(values.Count);
var filteredValues = new List<double>(values.Count); //used for calculating avg and sd