Skip to content

Instantly share code, notes, and snippets.

@ssell
ssell / FrustumPlanes.cs
Last active January 17, 2022 05:36
Implementation of a Unity ECS instanced Sprite renderer with basic frustum culling.
using Unity.Mathematics;
using Unity.Rendering;
using UnityEngine;
namespace Realms
{
/// <summary>
/// Based on Unity.Rendering.FrustumPlanes since those aren't public for some reason.
/// </summary>
public struct FrustumPlanes
@KANekT
KANekT / DeclensionGenerator
Created May 3, 2018 13:02
Склонение числительных в C#
public class DeclensionGenerator
{
/// <summary>
/// Возвращает слова в падеже, зависимом от заданного числа
/// </summary>
/// <param name="number">Число от которого зависит выбранное слово</param>
/// <param name="nominativ">Именительный падеж слова. Например "день"</param>
/// <param name="genetiv">Родительный падеж слова. Например "дня"</param>
/// <param name="plural">Множественное число слова. Например "дней"</param>
/// <returns></returns>
/*
Basic Sprite Shader for aligning pixel art to the same grid, based on the Unity Sprite Shader.
Create one Material where you assign the same Pixels Per Unit value you use on your imported Sprites,
then reuse this Material on all appropriate Sprite Renderers.
(You can use Shader.SetGlobalFloat to set that Pixels Per Unit value for all your shaders:
https://docs.unity3d.com/ScriptReference/Shader.SetGlobalFloat.html)
This is not for scaled or rotated artwork. If you need those features, look at low res render textures.
Use this however you want.
@radiatoryang
radiatoryang / SkinnedMeshObjectPreviewExample.cs
Last active November 14, 2024 03:08
An example of a custom ObjectPreview rendering out a SkinnedMesh for Unity Editor C#... I used it for facial expressions and blendshape editing, you might want to use it for something else. I hereby place it under MIT License. Full write-up here: http://www.blog.radiator.debacle.us/2016/06/working-with-custom-objectpreviews-and.html
using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
[CustomPreview(typeof(YourCustomScriptableObject))] // THIS IS VERY IMPORTANT, this is so the editor knows what this is supposed to be previewing at all
public class SkinnedMeshObjectPreviewExample : ObjectPreview {
PreviewRenderUtility m_PreviewUtility;
@staltz
staltz / introrx.md
Last active November 17, 2024 01:08
The introduction to Reactive Programming you've been missing
@smoothfriction
smoothfriction / .gitignore
Created May 3, 2012 20:41
.gitignore for visual studio
#OS junk files
[Tt]humbs.db
*.DS_Store
#Visual Studio files
*.[Oo]bj
*.user
*.aps
*.pch
*.vspscc
@lpalli
lpalli / gist:721397
Created November 30, 2010 09:15
C# Singleton
#region Constructor and Singleton
private static readonly Singleton _instance = new Singleton();
public static Singleton Instance
{
get { return _instance; }
}
private Singleton()