Skip to content

Instantly share code, notes, and snippets.

View joshcamas's full-sized avatar

Josh Steinhauer joshcamas

View GitHub Profile
@joshcamas
joshcamas / gist:77da838fcda2538dbe3c9d130ba9e97f
Last active January 22, 2019 07:08
unity3d base class with a few helpers.
//Note that Awake, Update, and Start functions could be implemented the same way Destroy is... however,
//This of course would probably result in a lot of unneeded mono events. So... yeah.
public class BaseBehavior : MonoBehaviour
{
//Transform cacheing
private Transform _transform;
public Transform Transform
{
@joshcamas
joshcamas / ProjectWindowHelper.cs
Last active November 11, 2024 03:45
Unity3D get / set project window search content
/*
* References:
* https://github.com/Unity-Technologies/UnityCsReference/blob/master/Editor/Mono/ProjectWindow/SearchFilter.cs
* https://github.com/jamesjlinden/unity-decompiled/blob/master/UnityEditor/UnityEditor/ProjectBrowser.cs
*/
public class ProjectWindowHelper
{
public struct ProjectSearch
{
@joshcamas
joshcamas / IsDirtyUtility.cs
Created March 18, 2019 14:44
Simple Utility script for Unity3D that allows access for "IsDirty" method for gameobjects.
using UnityEngine;
using UnityEditor;
using System.Reflection;
using System;
//Special thanks to Shamanim for solution
//https://forum.unity.com/threads/sorta-solved-check-if-gameobject-is-dirty.504894/#post-3967810
public class IsDirtyUtility
{
//Cached Value
@joshcamas
joshcamas / GuidComponent.cs
Created March 22, 2019 06:50
Unity3D Guid Saving
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
/*
* Saves custom GUID for a gameobject. Will automatically make sure
@joshcamas
joshcamas / DisableSelectAllOnFocus.cs
Last active September 7, 2019 13:55
Disabling annoying "select all on focus" for EditorUI.TextArea
//Just set EditorGUI.s_SelectAllOnMouseUp (an internal variable) to false every frame / every time you draw.
//This variable is usually set to true in certain circumstances, so we're overwriting the value.
//I honestly don't know why this feature exists, it's quite annoying and never useful.
//Of course, be sure to cache the field!
selectAllField = typeof(EditorGUI).GetField("s_SelectAllOnMouseUp", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Default);
selectAllField.SetValue(null, false);
@joshcamas
joshcamas / FullEditorStyles.cs
Created November 20, 2019 17:43
A helpful class that removes the annoyance of remembering the built in unity style strings
using UnityEngine;
using UnityEditor;
public class FullEditorStyles
{
public static GUIStyle CNBox => new GUIStyle("CN Box");
public static GUIStyle CNEntryInfo => new GUIStyle("CN EntryInfo");
public static GUIStyle CNEntryWarn => new GUIStyle("CN EntryWarn");
public static GUIStyle CNEntryError => new GUIStyle("CN EntryError");
public static GUIStyle CNEntryBackEven => new GUIStyle("CN EntryBackEven");
@joshcamas
joshcamas / AutoPresetAssetPostProcesser.cs
Created September 9, 2020 18:02
Automatically applies preset to folders recursively
using UnityEditor;
using UnityEditor.Presets;
using System.IO;
namespace Ardenfall
{
/// <summary>
/// Post Processer that automatically finds the nearest preset
@joshcamas
joshcamas / shader_distantpixelize.shader
Last active September 23, 2023 23:00
Distant Pixelize Unity Effect
Shader "Ardenfall/Effects/DistantPixelize"
{
HLSLINCLUDE
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
float _MaxPixelSize;
float _MinPixelSize;
float _MaxDistance;
@joshcamas
joshcamas / DistantPixelize.cs
Last active October 3, 2023 12:36
Distant Pixelize Renderer (Using SCPE)
using UnityEngine.Rendering.Universal;
using System;
using UnityEngine;
using UnityEngine.Rendering;
using SCPE;
namespace Ardenfall.Effects
{
[Serializable, VolumeComponentMenu("Ardenfall/Distant Pixelize")]