Skip to content

Instantly share code, notes, and snippets.

View ScriptFileWatcher.cs
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
namespace Naninovel
@Elringus
Elringus / FileWatcher.cs
Last active Dec 29, 2020
Allows executing an editor behaviour in response to file modificatons, even when editor application is not in focus.
View FileWatcher.cs
using System;
using System.Collections.Concurrent;
using System.IO;
using System.Threading.Tasks;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
/// <summary>
/// Uses file system watcher to track changes to specific files in the project directory.
View Item.cs
[System.Serializable]
public class Item
{
private string value = null;
public void SetValue (string value) => this.value = value;
public string GetValue () => value;
}
View UnlitAlphaRotation.shader
Shader "Custom/UnlitAlphaRotation"
{
Properties
{
_MainTex("Base (RGB) Trans (A)", 2D) = "white" {}
_RotationY("Rotation over Y-axis", Range(0, 360)) = 45
}
SubShader
@Elringus
Elringus / RenderMyCustomPass.cs
Last active Apr 16, 2021
Example for adding custom render passes via renderer features for lightweight render pipeline (LWRP)
View RenderMyCustomPass.cs
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.LWRP;
// Inheriting from `ScriptableRendererFeature` will add it to the
// `Renderer Features` list of the custom LWRP renderer data asset.
public class RenderMyCustomPass : ScriptableRendererFeature
{
private class MyCustomPass : ScriptableRenderPass
{
View rfc5646-language-tags.js
// List of language tags according to RFC 5646.
// See <http://tools.ietf.org/html/rfc5646> for info on how to parse
// these language tags. Some duplicates have been removed.
var RFC5646_LANGUAGE_TAGS = {
'af': 'Afrikaans',
'af-ZA': 'Afrikaans (South Africa)',
'ar': 'Arabic',
'ar-AE': 'Arabic (U.A.E.)',
'ar-BH': 'Arabic (Bahrain)',
'ar-DZ': 'Arabic (Algeria)',
View BlendOp.shader
Shader "BlendOp"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
[Enum(UnityEngine.Rendering.BlendOp)] _BlendOp("Blend Operation", Float) = 0.0
[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend("Source Blend", Float) = 1.0
[Enum(UnityEngine.Rendering.BlendMode)] _DstBlend("Destination Blend", Float) = 1.0
}
View TilemapRendererExtension.cs
using UnityEngine.Tilemaps;
using BlendModes;
[ExtendedComponent(typeof(TilemapRenderer))]
public class TilemapRendererExtension : RendererExtension<TilemapRenderer>
{
public override string[] GetSupportedShaderFamilies ()
{
return new[] {
"SpritesDefault"
View InverseSmoothStep.cs
#if LIVE2D_AVAILABLE
using Live2D.Cubism.Core;
using Live2D.Cubism.Framework;
using System.Collections.Generic;
using System.Linq;
using UnityCommon;
using UnityEngine;
namespace Naninovel
@Elringus
Elringus / Program.cs
Created Jun 25, 2018
Stubble render empty lines for non-existing tags
View Program.cs
using Stubble.Core.Builders;
using System;
class Program
{
static string template =
@"Lorem ipsum dolor sit amet, consectetur adipiscing elit.
{{{ATag}}}
{{{ATag}}}
{{{ATag}}}