Skip to content

Instantly share code, notes, and snippets.

View vinikkk's full-sized avatar

Vinie vinikkk

View GitHub Profile
@vinikkk
vinikkk / Singleton.cs
Created November 19, 2022 18:50 — forked from AlexMerzlikin/Singleton.cs
Unity Singleton
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class Singleton<T> : MonoBehaviour where T : Component
{
#region Fields
/// <summary>
@vinikkk
vinikkk / Singleton.cs
Created November 19, 2022 18:47 — forked from GkhanKINAY/Singleton.cs
Unity Singleton
// Docs : http://wiki.unity3d.com/index.php/Singleton
using UnityEngine;
/// <summary>
/// Be aware this will not prevent a non singleton constructor
/// such as `T myT = new T();`
/// To prevent that, add `protected T () {}` to your singleton class.
///
/// As a note, this is made as MonoBehaviour because we need Coroutines.
@vinikkk
vinikkk / SingletonUnity.cs
Created November 19, 2022 18:37 — forked from iletai/SingletonUnity.cs
Singleton
public class Singleton<T> where T : new()
{
private static T singleton = new T();
public static T instance
{
get
{
return singleton;
}
@vinikkk
vinikkk / MonoBehaviourSingleton.cs
Created November 19, 2022 18:37 — forked from mstevenson/MonoBehaviourSingleton.cs
Generic Singleton classes for Unity. Use MonoBehaviourSingletonPersistent for any singleton that must survive a level load.
using UnityEngine;
using System.Collections;
public class MonoBehaviourSingleton<T> : MonoBehaviour
where T : Component
{
private static T _instance;
public static T Instance {
get {
if (_instance == null) {
@vinikkk
vinikkk / TemplateFeature.cs
Created September 19, 2022 14:40 — forked from alexanderameye/TemplateFeature.cs
URP 12 ScriptableRendererFeature Template
// ScriptableRendererFeature template created for URP 12 and Unity 2021.2
// Made by Alexander Ameye
// https://alexanderameye.github.io/
using UnityEngine;
using UnityEngine.Rendering.Universal;
public class TemplateFeature : ScriptableRendererFeature
{
[System.Serializable]
@vinikkk
vinikkk / TemplatePass.cs
Created September 19, 2022 14:39 — forked from alexanderameye/TemplatePass.cs
URP 12 ScriptableRenderPass Template
// ScriptableRenderPass template created for URP 12 and Unity 2021.2
// Made by Alexander Ameye
// https://alexanderameye.github.io/
using System;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
public class TemplatePass : ScriptableRenderPass
@vinikkk
vinikkk / ScreenRecorder.cs
Created September 17, 2022 22:28 — forked from DashW/ScreenRecorder.cs
ScreenRecorder - High Performance Unity Video Capture Script
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading;
class BitmapEncoder
{
public static void WriteBitmap(Stream stream, int width, int height, byte[] imageData)