Skip to content

Instantly share code, notes, and snippets.

@Westerveld
Westerveld / SetColliderSizeFromScale.cs
Last active April 12, 2019 01:07
This can be used in unity to convert the scale of the object to be the size of its collider. Note: it does also remove the mesh and resets the scale of the object
// Ethan Bruins 2019
// https://gist.github.com/Westerveld/fc81c4f51846c7153df8715fe5b76ddd
using UnityEngine;
using UnityEditor;
public class SetColliderSizeFromScale : EditorWindow
{
//Shows up in the hierachy when placed in the GameObject menu
[MenuItem("GameObject/Convert Scale To Collider", false, 0)]
@quaternioninterpolation
quaternioninterpolation / ImageDOCrossfade.cs
Last active October 7, 2025 09:35
DOTween UnityEngine.UI.Image image cross fade
/** --
** Copyright (C) 2019 by Josh van den Heever
**
** Permission is hereby granted, free of charge, to any person obtaining a copy of
** this software and associated documentation files (the "Software"), to deal in
** the Software without restriction, including without limitation the rights to
** use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
** of the Software, and to permit persons to whom the Software is furnished to
** do so, subject to the following conditions:
**
package org.veiset.tsar.world
import com.badlogic.gdx.math.Vector2
import org.veiset.tsar.engine2.utils.component1
import org.veiset.tsar.engine2.utils.component2
import org.veiset.tsar.engine2.utils.x
import org.veiset.tsar.world.icon.WorldIcon
import kotlin.math.absoluteValue
import kotlin.math.cos
import kotlin.math.pow
@robertwahler
robertwahler / entity.cs
Created January 22, 2019 16:24
Non allocating, lazy loaded, Unity Physics.OverlapSphere
/// <summary>
/// Collider cache for non allocating physics calls. Lazy loaded.
/// </summary>
/// <example>
/// Usage
/// <code>
/// float radius = 0.2f;
/// int colliderCount = Physics.OverlapSphereNonAlloc(transform.position, radius: radius, results: ColliderCache);
/// for (int i = 0; i<colliderCount; i++) {
/// ...
@Shmaug
Shmaug / VoxelTools.cs
Last active September 22, 2018 18:43
using UnityEngine;
using System.IO;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class VoxelTools {
#if UNITY_EDITOR
@JackDraak
JackDraak / FishDrone.cs
Last active February 16, 2022 17:41
Unity2018 - scripting autonomous fish drones: avoiding obstacles using raycast
/// FishDrone by JackDraak
/// July 2018
/// 'changelog' viewable on GitHub.
///
using UnityEngine;
public class FishDrone : MonoBehaviour
{
private Animator animator;
private float changeDelay, changeTime;
@msklywenn
msklywenn / BatchBuilderSettings.cs
Last active May 18, 2022 14:32
Unity Batch Builder
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
// Version 2, December 2004
//
// Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
//
// Everyone is permitted to copy and distribute verbatim or modified
// copies of this license document, and changing it is allowed as long
// as the name is changed.
//
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@cortvi
cortvi / !Refractive Surface Shader.md
Last active March 31, 2022 22:55
Custom refractive liquid surface shader
We couldn’t find that file to show.
@dvddarias
dvddarias / SingletonScriptableObject.cs
Last active February 27, 2025 13:44
Better Unity Singleton Class
/************************************************************
* Better Singleton by David Darias
* Use as you like - credit where due would be appreciated :D
* Licence: WTFPL V2, Dec 2014
* Tested on Unity v5.6.0 (should work on earlier versions)
* 03/02/2017 - v1.1
* **********************************************************/
using System;
using UnityEngine;
using System.Collections.Generic;
using UnityEngine;
public class Pool : MonoBehaviour
{
private const int DEFUALT_POOL_SIZE = 100;
private static Dictionary<IPoolable, Pool> pools = new Dictionary<IPoolable, Pool>();
public static Pool GetPool(IPoolable prefab)