Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
‏‏‎

mika unitycoder

‏‏‎
View GitHub Profile
Shader "Test/SmoothZoomTexture"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
[KeywordEnum(Basic,Manual,Blend,Compare)]Mode("Mode", Int) = 0
_Blend("Blend", Range(0,1)) = 1
[Header(Mip Map)]
_MipMapMin("MipMap Min", Int) = 4
@kurtdekker
kurtdekker / MatchTerrainToColliders.cs
Created August 18, 2021 13:55
Matching Unity3D terrain to arbitrary colliders
//
// Script originally from user @Zer0cool at:
//
// https://forum.unity.com/threads/terrain-leveling.926483/
//
// Revamped by @kurtdekker as follows:
//
// - put this on the object (or object hierarchy) with colliders
// - drag the terrain reference into it
// - use the editor button to "Stamp"
@Invertex
Invertex / CustomHoldingInteraction.cs
Last active January 17, 2025 02:57
Unity New Input System custom Hold "Interaction" where the .performed callback is constantly triggered while input is held.
using UnityEngine;
using UnityEngine.InputSystem;
//!!>> This script should NOT be placed in an "Editor" folder. Ideally placed in a "Plugins" folder.
namespace Invertex.UnityInputExtensions.Interactions
{
//https://gist.github.com/Invertex
/// <summary>
/// Custom Hold interaction for New Input System.
/// With this, the .performed callback will be called everytime the Input System updates.
@mmozeiko
mmozeiko / shader.hlsl
Last active November 7, 2024 20:23
compute shader for rendering monospaced glyphs in grid
//
struct TerminalCell
{
// cell index into GlyphTexture, should be two 16-bit (x,y) values packed: "x | (y << 16)"
uint GlyphIndex;
// 0xAABBGGRR encoded colors, nonzero alpha for Foreground indicates to render colored-glyph
// which means use RGB values from GlyphTexture directly as output, not as ClearType blending weights
uint Foreground;
@x1unix
x1unix / NET-framework-standalone-exe.md
Last active March 13, 2025 11:10
[C#] Embed DLL assemblies onto executable

Summary

This guide tells how to embed CLR assemblies (.dll) onto a single executable. This works for WPF, WinForms and console .NET applications.

Source - original article

Project settings

First, we need to add special section to .csproj file to make MSBuild embed referenced assemblies

@grapefrukt
grapefrukt / CornerCheat.cs
Created April 7, 2021 12:01
Makes a CircleCollider2D slide smoothly along the inner edge of a rounded EdgeCollider2D
using UnityEngine;
public class CornerCheat : MonoBehaviour {
public CircleCollider2D circle;
public Rigidbody2D body;
EdgeCollider2D edge;
[Range(0, .2f)] public float distanceThreshold = .03f;
[Range(0, 1)] public float dotThreshold = .96f;
@JoseMiguelPizarro
JoseMiguelPizarro / PreviewData.cs
Created April 6, 2021 15:17
Rendering preview window in Unity
using UnityEngine;
[CreateAssetMenu(menuName ="Data/PreviewData")]
public class PreviewData : ScriptableObject
{
public Color previewColor;
}
@dasannikov
dasannikov / TheThing.cs
Last active April 8, 2023 17:07
Unity Coding Guidelines
using UnityEngine;
using System.Collections;
namespace CompanyName {
public class TheThing : MonoBehaviour {
// 1
// Public fields section. Try to avoid public fields.
@MattRix
MattRix / CurvatureImageEffect.shader
Last active February 2, 2024 20:15
Cavity/Curvature image effect shader based on the Blender node graph in this post: https://blender.community/c/rightclickselect/J9bbbc/
Shader "Milkbag/CurvatureImageEffect"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_LightStrength ("LightStrength", Float) = 0.3
_DarkStrength ("DarkStrength", Float) = 0.3
_Spread ("Spread", Float) = 1.0
[Toggle(USE_MULTIPLY)] _UseMultiply("Use Multiply", Float) = 0
[Toggle(CURVATURE_ONLY)] _CurvatureOnly("Curvature Only", Float) = 0
@bgolus
bgolus / WorldNormalFromDepthTexture.shader
Last active March 5, 2025 00:57
Different methods for getting World Normal from Depth Texture, without any external script dependencies.
Shader "WorldNormalFromDepthTexture"
{
Properties {
[KeywordEnum(3 Tap, 4 Tap, Improved, Accurate)] _ReconstructionMethod ("Normal Reconstruction Method", Float) = 0
}
SubShader
{
Tags { "RenderType"="Transparent" "Queue"="Transparent" }
LOD 100