This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Sometimes, RenderTexture.GetTemporary() and RenderTexture.ReleaseTemporary() leak textures. | |
| // For those times, there is RenderTexturePool. | |
| using System.Collections.Generic; | |
| using Unity.Collections; | |
| using UnityEngine; | |
| public class RenderTexturePool { | |
| readonly Dictionary<RenderTextureDescriptor, List<RenderTextureCounter>> _pool; | |
| readonly int _initialListCapacity; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class NativeListExtensions { | |
| public static unsafe void UnsafeAddRange<T>(this NativeList<T> nativeList, void* ptr, int length) where T: struct { | |
| int idx = nativeList.Length; | |
| int newCount = idx + length; | |
| if (nativeList.Capacity < newCount) { | |
| nativeList.Resize(nativeList.Capacity + length, NativeArrayOptions.UninitializedMemory); | |
| } | |
| nativeList.Length = newCount; | |
| int stride = UnsafeUtility.SizeOf<T>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using Unity.Mathematics; | |
| public static class AnimationCurveExtensions { | |
| public static Texture2D ToLUT(this AnimationCurve curve, int width, bool apply = true) { | |
| // create texture | |
| Texture2D tex = new Texture2D(width, 1, TextureFormat.R8, 0, true); | |
| float x = 0f; | |
| float t = 0f; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.IO; | |
| using System.Collections; | |
| using UnityEngine; | |
| public class DelayedCaptureBehaviour: MonoBehaviour { | |
| public new Camera camera; | |
| public int delayFrames; | |
| public KeyCode targetKey; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // CenteredCollectionViewFlowLayout.swift | |
| // censr | |
| // | |
| // Created by Sam Loeschen on 5/30/20. | |
| // Copyright © 2020 Sam Loeschen. All rights reserved. | |
| // | |
| import Foundation | |
| import UIKit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // CenteredCollectionViewFlowLayout.swift | |
| // ACameraAppwithBlur | |
| // | |
| // Created by Sam Loeschen on 5/30/20. | |
| // Copyright © 2020 Sam Loeschen. All rights reserved. | |
| // | |
| import Foundation | |
| import UIKit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdlib.h> | |
| #include <stdio.h> | |
| #include "sparseset.h" | |
| int min(int a, int b) { | |
| return a < b ? a : b; | |
| } | |
| int max(int a, int b) { | |
| return a > b ? a : b; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| public class ContiguousMap<T> { | |
| int[] _idIndexMap; | |
| int[] _idPool; | |
| int _poolCount = 0; | |
| int _nextId = 0; | |
| public T[] values { | |
| get { return _values; } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Shader "Custom/Unlit/CrescentAnimation" | |
| { | |
| Properties | |
| { | |
| [PerInstanceData] _Anim ("Animation", Range(0, 1)) = 0 | |
| [PerInstanceData] _Flash ("Flash", Range(0, 1)) = 0 | |
| [PerInstanceData] _Color ("Color", Color) = (1,1,1,1) | |
| [PerInstanceData] _OffsetDir ("Offset Direction", Vector) = (0.5, 0.5, 0, 0) | |
| _Displacement ("Displacement", Float) = 0.65 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using System.Collections.Generic; | |
| public static class LayerMaskExtensions { | |
| // int extensions | |
| public static int Inverse(this int mask) { | |
| return ~mask; | |
| } | |
| public static int Combined(this int mask, int other) { | |
| return mask | other; |