Skip to content

Instantly share code, notes, and snippets.

@nothke
nothke / LOD.cs
Last active November 27, 2021 12:34
[Unity] A simple and fast LOD system
// Update: not needed for Unity 5 since LOD groups are available in personal edition
//========================================
//== Simple LOD system ==
//== File: LOD.cs ==
//== By: Ivan Notaros - Nothke ==
//== Use and alter Freely ==
//========================================
//Description:
@nothke
nothke / PitchShift.cs
Last active December 18, 2022 01:40
Unity C# Keyboard keys to pitch of a sound conversion
///
/// Changes pitch of any audio clip to match a pressed key on a (piano) keyboard
/// if a sound is in C4 (440hz) then it will perfectly match the scale
/// by Nothke
///
/// QWERTY.. row for white keys
/// 12345... row for black keys
/// press C to toggle chord mode in game
/// press N or M for minor or major
/// press A to toggle arpeggiate
using UnityEngine;
using System.Collections;
public class PhotonCam : MonoBehaviour
{
public float speed = 10;
public float rayLength = 0.3f;
public int gizmoReflections = 10;
@nothke
nothke / SReader.cs
Last active July 7, 2016 13:36
Simple text reader for lists
using UnityEngine;
using System.Collections.Generic;
using System.IO;
public class SReader
{
public static string[] GetLines(string path, string key)
{
if (!File.Exists(path))
Debug.LogWarning("SReader: File named " + path + " doesn't exist");
//
// ParticleSystem extensions for changes introduced in Unity 5.3
// by Nothke, unlicensed
//
// Each module in ParticleSystem in Unity 5.3 is now a struct,
// which makes setting some simple stuff more cumbersome
// These extensions provide shortcuts to simplify those tasks
//
// For example: setting constant emission rate now takes 3 lines at minimum,
// rather than a single line like before.
@nothke
nothke / Draw.cs
Last active January 20, 2024 06:58
///
/// Draw lines at runtime
/// by Nothke
/// unlicensed, aka do whatever you want with it
/// made during Stugan 2016 :)
/// ..(it's midnight, and Robbie clicks A LOT, LOUDLY!)
///
/// Important:
/// - Should be called in OnPostRender() (after everything else has been drawn)
/// therefore the script that calls it must be attached to the camera
using UnityEngine;
[ExecuteInEditMode]
public class Darken : MonoBehaviour
{
Material mat;
void Start()
{
//GetComponent<Camera>().depthTextureMode = DepthTextureMode.Depth;
Shader "Custom/FlatShading"
{
Properties
{
_Color("Color", Color) = (1,0,0,1)
}
SubShader
{
////////////////////////////////////////////////////////////////
// Upgrade NOTE: excluded shader from DX11, Xbox360, OpenGL ES 2.0 because it uses unsized arrays
#pragma exclude_renderers d3d11 xbox360 gles
//
// HG_SDF
//
// GLSL LIBRARY FOR BUILDING SIGNED DISTANCE BOUNDS
//
// version 2016-01-10
//
///
/// Placas objects dynamically around the player
/// by Nothke
///
/// unlicensed, aka do whatever you want with it
///
using UnityEngine;
using System.Collections.Generic;