Skip to content

Instantly share code, notes, and snippets.

@garrafote
garrafote / UnityAsyncOperationHandleExtensions.cs
Created April 9, 2020 00:47
UniTask extension methods for addressables AsyncOperationHandle
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using UnityEngine.ResourceManagement.AsyncOperations;
using System;
using System.Threading;
using UniRx.Async.Internal;
namespace UniRx.Async
{
public static class UnityAsyncOperationHandleExtensions
@garrafote
garrafote / normalize
Last active August 29, 2015 14:18
C++ function to normalize 8bit input into [-1 1] range with a deadzone in the middle.
// Normalizes a 8 bit integer value into [-1 1] range.
// The deadzone is the middle portion of the 8 bit range
// to be considered as 0 output. For a deadzone [dz] value
// of n, the deadzone range will be [127-n 128+n].
//
// in = 0 (127 - dz) (128 + dz) 255
// out = -1 0 0 1
// <---x-----------x--------------x----------x--->
// |______________|
// 2 * dz
<!DOCTYPE html>
<html>
<head>
<script src="http://cdnjs.cloudflare.com/ajax/libs/three.js/r67/three.min.js"></script>
<style>
body { margin: 0; }
canvas { width: 100%; height: 100%; }
#container { width: 400; height: 400; }
</style>
<meta charset="utf-8">