Skip to content

Instantly share code, notes, and snippets.

View Petethegoat's full-sized avatar
😍

Pete Goodfellow Petethegoat

😍
View GitHub Profile
@antonkudin
antonkudin / RenameAttribute.cs
Created November 21, 2023 02:49
Rename variable names inside your properties
using UnityEngine;
#if UNITY_EDITOR
[System.AttributeUsage(System.AttributeTargets.Field)]
public class RenameAttribute : PropertyAttribute
{
public string[] renamePairs;
public RenameAttribute(params string[] renamePairs)
{
@jschieck
jschieck / FlyoutProjectWindow.cs
Last active March 2, 2024 12:43
Show a flyout project window in the scene view
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.Compilation;
using UnityEngine;
public static class FlyoutProjectWindow
{
@bgolus
bgolus / MatCapTechniques.shader
Created January 29, 2022 00:37
Showing multiple matcap techniques, including a proposed improved method that's no more expensive than the usual fix if you're starting with the world position and world normal.
Shader "Unlit/MatCap Techniques"
{
Properties
{
[NoScaleOffset] _MatCap ("MatCap", 2D) = "white" {}
[KeywordEnum(ViewSpaceNormal, ViewDirectionCross, ViewDirectionAligned)] _MatCapType ("Matcap UV Type", Float) = 2
}
SubShader
{
Tags { "RenderType"="Opaque" }
@FreyaHolmer
FreyaHolmer / SceneViewZAlign.cs
Last active November 27, 2023 11:32
Allows the scene view camera to use Z up/down (be sure to place this script in an Editor/ folder)
// Allows you to change the up vector in the scene view to the Z axis.
// Y-up mode uses Unity's default implementation.
//
// Original code from Akulist on the Unity forums, modified by Freya Holmér:
// • Fixed orbit+RMB zoom not working
// • Toggling will now align the camera immediately to the new up vector
// • When the camera is upside down in Z axis mode, left/right orbit will no longer be mirrored (pls fix this too Unity~)
// • Moved toggle buttons to under the gizmo
// • Fixed broken rotation state when focusing a different window in Unity and coming back to the scene view
//
@totallyRonja
totallyRonja / MaterialGradientDrawer.cs
Last active September 26, 2023 09:46
A Material Property Drawer for the [Gradient] attribute which lets you edit gradients and adds them to the shader as textures. More information here: https://twitter.com/totallyRonja/status/1368704187580682240
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
public class MaterialGradientDrawer : MaterialPropertyDrawer {
private int resolution;
@ompuco
ompuco / PSXDither.hlsl
Last active February 10, 2024 10:54
Color dither & truncation based on Sony's PlayStation (1) hardware features & limitations.
#ifdef PSXDTH
#else
#define PSXDTH
//PS1 Hardware Dithering & Color Precision Truncation Function
//by ompu co | Sam Blye (c) 2020
//PS1 dither table from PSYDEV SDK documentation
@roguesleipnir
roguesleipnir / ShaderOccurence.cs
Last active August 2, 2022 11:18
Material/Shader reference searcher. Find materials that use a shader by name string. Find materials with missing shader or errors. Original snippet from https://answers.unity.com/questions/510945/find-materials-that-use-a-certain-shader.html
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using System.IO;
//https://answers.unity.com/questions/510945/find-materials-that-use-a-certain-shader.html
public class ShaderOccurenceWindow : EditorWindow {
[MenuItem ("Tools/Shader Occurence")]
public static void Open () {
@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
@ProGM
ProGM / ExampleBehavior.cs
Created October 19, 2016 10:39
A PropertyDrawer to show a popup field with a generic list of string for your Unity3d attribute
public class MyBehavior : MonoBehaviour {
// This will store the string value
[StringInList("Cat", "Dog")] public string Animal;
// This will store the index of the array value
[StringInList("John", "Jack", "Jim")] public int PersonID;
// Showing a list of loaded scenes
[StringInList(typeof(PropertyDrawersHelper), "AllSceneNames")] public string SceneName;
}
using UnityEngine;
using System.Collections;
// based on http://unitytipsandtricks.blogspot.com/2013/05/camera-shake.html
public class PerlinShake : MonoBehaviour
{
public float duration = 2f;
public float speed = 20f;
public float magnitude = 2f;
public AnimationCurve damper = new AnimationCurve(new Keyframe(0f, 1f), new Keyframe(0.9f, .33f, -2f, -2f), new Keyframe(1f, 0f, -5.65f, -5.65f));