Skip to content

Instantly share code, notes, and snippets.

@PopupAsylum
PopupAsylum / IsBetween0And1.cginc
Created September 23, 2016 14:07
Returns 1 if 0<=x<1, 0 otherwise
//returns 1 if 0<=x<1, 0 otherwise
float IsBetween0And1(float x) {
return 1 - saturate(floor(abs((x-0.5)*2)));
}
float3 GetAxis(float3 input) {
input = normalize(input) ;
float3 signs = sign(input) ;
float3 abss = abs(input) ;
float maxs = max(abss.x, max(abss.y, abbs.z));
return floor(abss/maxs) * signs;
}
@PopupAsylum
PopupAsylum / ConveyorBelt.cs
Created September 23, 2016 10:07
A behaviour that makes a rigidbody act like a conveyor, moving rigidbodies that collide with it without moving itself
using UnityEngine;
using System.Collections;
public class ConveyorBelt : MonoBehaviour {
public float speed = 2.0f;
void FixedUpdate()
{
Rigidbody rigidbody = GetComponent<Rigidbody>();
@PopupAsylum
PopupAsylum / PreviewCulling.cs
Created September 23, 2016 08:45
When attached to a Camera, shows that cameras frustum culling in the scene view
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
using System.Collections;
[ExecuteInEditMode]
public class PreviewCulling : MonoBehaviour {
#if UNITY_EDITOR