Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
✅
‏‏‎

mika unitycoder

✅
‏‏‎
View GitHub Profile
@unitycoder
unitycoder / ClickableLabel.cs
Created October 11, 2022 18:03
EditorGUILayout clickable label text (instead of clicking toggle checkbox only)
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("Create Folders", EditorStyles.label)) createFolders = !createFolders;
createFolders = EditorGUILayout.Toggle("", createFolders);
EditorGUILayout.EndHorizontal();
@unitycoder
unitycoder / AA.shader
Created October 13, 2022 06:15
Anti Aliased Texture Sampling Shader
// https://www.shadertoy.com/view/csX3RH
vec4 texture2DAA(sampler2D tex, vec2 uv) {
vec2 texsize = vec2(textureSize(tex,0));
vec2 uv_texspace = uv*texsize;
vec2 seam = floor(uv_texspace+.5);
uv_texspace = (uv_texspace-seam)/fwidth(uv_texspace)+seam;
uv_texspace = clamp(uv_texspace, seam-.5, seam+.5);
return texture(tex, uv_texspace/texsize);
}
@unitycoder
unitycoder / distantPosition.cs
Created October 19, 2022 06:32
Get New Position At an Angle from Current position
// https://forum.unity.com/threads/get-position-at-an-angle.1036405/
//- zero is straight up (Vector3.up)
//- your angle is in degrees in angle
//- the distance is in distance (world units)
//- whereIAmRightNow is where we are right now,
Vector3 distantPosition = whereIAmRightNow + Quaternion.Euler( 0, 0, angle) * Vector3.up * distance;
@unitycoder
unitycoder / DepthTest.shader
Created October 21, 2022 11:20
DepthTest average
// https://forum.unity.com/threads/how-to-predict-depth-value-of-a-nearby-pixel.1351388/
Shader "DepthTest"
{
    Subshader
    {
        Pass
        {
            CGPROGRAM
            #pragma vertex VSMain
            #pragma fragment PSMain
@unitycoder
unitycoder / MonoExtensions.cs
Created October 26, 2022 13:04 — forked from mstfmrt07/MonoExtensions.cs
A simple C# extension to easily create WaitForSeconds coroutines
using System.Collections;
using UnityEngine;
using UnityEngine.Events;
public static class MonoExtensions
{
public static Coroutine Wait(this MonoBehaviour mono, float delay, UnityAction action)
{
return mono.StartCoroutine(ExecuteAction(delay, action));
}
@unitycoder
unitycoder / unity-messed-up.md
Last active December 15, 2022 12:38
Unity Good & Bad

Collecting things where Unity did something nice or when they messed up (just to keep track)

Bad

Shader "Name" {
Properties {
_Name ("display name", Range (min, max)) = number
_Name ("display name", Float) = number
_Name ("display name", Int) = number
_Name ("display name", Color) = (number,number,number,number)
_Name ("display name", Vector) = (number,number,number,number)
@unitycoder
unitycoder / Constant Scale Quad.shader
Created November 2, 2022 17:37
Constant Scale Quad shader fixed-size-billboard
// https://forum.unity.com/threads/need-help-fixed-size-billboard.688054/
Shader "Unlit/Constant Scale Quad"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
@unitycoder
unitycoder / ColorAdjust.shader
Created November 5, 2022 18:43
Shader to adjust: Hue Brightness Contrast Saturation
// https://forum.unity.com/threads/hue-saturation-brightness-contrast-shader.260649/#post-4693943
Shader "Unlit/ColorAdjust"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
        _Hue ("Hue", Range(-360, 360)) = 0.
        _Brightness ("Brightness", Range(-1, 1)) = 0.
        _Contrast("Contrast", Range(0, 2)) = 1
        _Saturation("Saturation", Range(0, 2)) = 1
@unitycoder
unitycoder / hub.txt
Last active August 6, 2024 12:09
Unity Hub Notes
-----------
-----------
-----------
-----------
-----------
-----------
-----------
-----------
-----------
-----------