Skip to content

Instantly share code, notes, and snippets.

@elringus
elringus / Program.cs
Created June 25, 2018 07:31
Stubble render empty lines for non-existing tags
using Stubble.Core.Builders;
using System;
class Program
{
static string template =
@"Lorem ipsum dolor sit amet, consectetur adipiscing elit.
{{{ATag}}}
{{{ATag}}}
{{{ATag}}}
/// <summary>
/// Checks whether string is null, empty or consists of whitespace chars.
/// </summary>
public static bool IsNullEmptyOrWhiteSpace (string content)
{
if (String.IsNullOrEmpty(content))
return true;
return String.IsNullOrEmpty(content.TrimFull());
}
@elringus
elringus / SpriteGradientHSBC.shader
Last active January 8, 2018 11:12
Incorporates HSBC effects and gradient overlay blending for sprites.
// Incorporates HSBC effects and gradient overlay blending for sprites.
Shader "BlendModes/Extra/SpriteGradientHSBC"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_OverlayTex("Overlay Texture", 2D) = "white" {}
_OpacityTex("Opacity Mask", 2D) = "clear" {}
Shader "UI/Outline"
{
Properties
{
[PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
_Color("Tint", Color) = (1,1,1,1)
[MaterialToggle] PixelSnap("Pixel snap", Float) = 0
[Toggle]_IsOutlineEnabled("Enable Outline", int) = 0
[HDR]_OutlineColor("Outline Color", Color) = (1,1,1,1)
@elringus
elringus / NovelActorPerformance.cs
Created December 6, 2017 20:51
Promise aggregation
using UnityCommon;
/// <summary>
/// Represents a set of async actions performed by a <see cref="INovelActor"/> over time.
/// </summary>
public class NovelActorPerformance : AsyncAction<INovelActor>
{
public INovelActor Actor { get { return State; } }
private int performancesCount;
Shader "BlendModes/Extra/UIOverlay"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_OverlayTex1("Overlay Texture 1", 2D) = "white" {}
_OverlayTex2("Overlay Texture 2", 2D) = "white" {}
_OverlayTex3("Overlay Texture 3", 2D) = "white" {}
_OverlayTex4("Overlay Texture 4", 2D) = "white" {}
_OverlayTex5("Overlay Texture 5", 2D) = "white" {}
using UnityEngine;
namespace BlendModes
{
[RequireComponent(typeof(BlendModeEffect))]
public class TintColorUpdater : MonoBehaviour
{
private BlendModeEffect blendModeEffect;
private void Awake ()
using UnityEngine;
using System.Collections.Generic;
[System.Serializable]
public struct ColorMapping
{
public KeyCode KeyCode;
public Color Color;
}
@elringus
elringus / ReadOnlyAttribute.cs
Created June 29, 2017 14:06
ReadOnly property drawer for Unity: add a [ReadOnly] attribute to a serialized field to make it show up as read only in the inspector
// Put this outside of an 'Editor' folder.
using UnityEngine;
public class ReadOnlyAttribute : PropertyAttribute { }
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
public class SpriteChanger : MonoBehaviour
{
public List<Sprite> Sprites = new List<Sprite>();
public float ChangeRate = 2f;
private Image image;