Skip to content

Instantly share code, notes, and snippets.

View Hotrian's full-sized avatar
💭
Coding!

Nicholas Ewalt Hotrian

💭
Coding!
View GitHub Profile

Version 2 - now with LayerMask support

Automatic texture desaturation with Unity Light System based color reveal - Textures are converted in realtime to grayscale and Point/Directional/Spot lights reveal the original color of a texture. This is just a quick and dirty example.

Made for URP (3d) and tested in Unity 6000.0.30f1

img

img

Version 2 is out now

Automatic texture desaturation with Unity Light System original color reveal - Textures are converted in realtime to grayscale and Point/Directional/Spot lights reveal the original color of a texture.

img

Quick Example Vid on YouTube

More details in this comment thread probably

The code given here is an example and not for production usage.

See the blog entry for more information.

The code given here is a very simplified example and not for production usage.

The following snippet demonstrates TAP Task Synchronization using SemaphoreSlims in the context of upgrading an existing EAP application which relies on lock statements. This snippet of code doesn't do anything particularly useful, because it isn't supposed to - it is only to demonstrate one way of migrating from the EAP model to the TAP model.

See the blog entry for more information.

<?xml version="1.0" encoding="utf-8"?>
<Translation>
<QuickAccessTitle>OVRdrop Settings Quick Access</QuickAccessTitle>
<QuickAccessAdvanced>Advanced</QuickAccessAdvanced>
<QuickAccessHotkeys>Hotkeys</QuickAccessHotkeys>
<QuickAccessAutoSwap>Auto Swap</QuickAccessAutoSwap>
<QuickAccessQuickSwap>Quick Swap</QuickAccessQuickSwap>
<AdvancedSettingsLeftTitle>{b}Target Application Settings{/b}</AdvancedSettingsLeftTitle>
<AdvancedSettingsLeftText2>{b}Window Settings{/b}
@Hotrian
Hotrian / Prusa Research Original Prusa i3 MK3.fff
Created February 24, 2018 01:37
[Unmodified] Prusa Research Original Prusa i3 Mk3 FFF (S3D 4.0.1)
<?xml version="1.0"?>
<profile name="Prusa Research Original Prusa i3 MK3" version="2018-01-19 08:00:00" app="S3D-Software 4.0.0">
<baseProfile></baseProfile>
<printMaterial>PLA</printMaterial>
<printQuality>Medium</printQuality>
<printExtruders></printExtruders>
<extruder name="Primary Extruder">
<toolheadNumber>0</toolheadNumber>
<diameter>0.4</diameter>
<autoWidth>0</autoWidth>
@Hotrian
Hotrian / SpriteResizer.cs
Last active July 13, 2018 08:12
Automatically Scales Sprite Texture2Ds, allowing you to multiply the image size safely, and effectively. Not guaranteed to work on every Sprite, or at all for that matter :P.
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
/* Unity Sprite Resizer v1.6 © Hotrian 2017
*
* This has only been tested on PNG files.
*
* Usage instructions:
@Hotrian
Hotrian / ProtoMesh.cs
Last active April 20, 2024 07:11
Example code for simple Quad and Cube meshes built through code.
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(MeshFilter)), RequireComponent(typeof(MeshRenderer))]
public class ProtoMesh : MonoBehaviour
{
#region Helper Properties
// Simple helpers to cache the MeshFilter and MeshRenderer
public MeshRenderer MyMeshRenderer
{
@Hotrian
Hotrian / HeadlessScript.cs
Last active September 17, 2020 23:54
Takes a normal Unity Standalone Player Window and hides it off screen and from the Taskbar :). This was made because -batchmode seems to automatically call -nographics now, which breaks things :(.
using System;
using UnityEngine;
using System.Runtime.InteropServices;
public class HeadlessScript : MonoBehaviour
{
#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
static extern IntPtr FindWindowByCaption(IntPtr zeroOnly, string lpWindowName);
@Hotrian
Hotrian / PolygonDrawScript.cs
Last active December 30, 2019 17:39
PolygonCollider2D Mesh Draw Scripts. These 3 scripts allow you to visualize a PolygonCollider2D as a mesh in the Unity game world. Can be used during Edit Mode also to permanently save the Mesh to the scene, but note the Start() method of PolygonDrawScript currently rebuilds the mesh when the game starts anyway. See: https://www.reddit.com/r/Uni…
// Note this file goes in Assets/
using UnityEngine;
using System.Collections.Generic;
[RequireComponent(typeof(PolygonCollider2D), typeof(MeshFilter), typeof(MeshRenderer))] // require PolygonCollider2D, MeshFilter, and MeshRenderer
public class PolygonDrawScript : MonoBehaviour
{
private PolygonCollider2D Poly
{