Skip to content

Instantly share code, notes, and snippets.

@gekidoslair
gekidoslair / PhysicsSettler.cs
Created December 30, 2019 23:58
Activate physics in Edit mode to dynamically drop or settle objects in a scene
using UnityEngine;
using UnityEditor;
using UnityEditor.ShortcutManagement;
namespace PixelWizards.Utilities
{
// This causes the class' static constructor to be called on load and on starting playmode
[InitializeOnLoad]
class PhysicsSettler
@gekidoslair
gekidoslair / DistributeEvenly.cs
Last active January 26, 2020 12:18
Distribute GameObjects in a scene evenly (along x, y or z axis)
using UnityEngine;
using UnityEditor;
using UnityEditor.ShortcutManagement;
namespace PixelWizards.Utilities
{
// This causes the class' static constructor to be called on load and on starting playmode
[InitializeOnLoad]
class PhysicsSettler
@mycodingdad
mycodingdad / AR Proxy.shader
Created September 30, 2019 14:54
Unity shader for Universal RP and AR Foundation, renders as transparent with occlusion and shadows. Put this on AR planes to get shadows and occlusion for 3D objects.
Shader "AR Proxy"
{
Properties
{
}
SubShader
{
Tags
{
@ArztSamuel
ArztSamuel / ParkingCarAgent.cs
Last active November 13, 2024 06:14
Most important parts of the Agent code used for the project of https://youtu.be/VMp6pq6_QjI
public class ParkingCarAgent : Agent
{
[SerializeField]
private Transform TargetParkingSpot;
[SerializeField]
// = Reward every 'interval' units getting closer
private float DistanceRewardInterval = 3f;
// Thresholds defining when the task is complete
@acoget
acoget / EnumToPrefab.cs
Last active September 29, 2025 17:12
A PropertyDrawer to assign one prefab per enum value
using System;
using UnityEngine;
using UnityEditor;
/*
* A custom PropertyDrawer to assign one prefab to each value in an enum.
* Makes for less error-prone editing, avoids a gazillion asserts at runtime,
* and even looks nice.
* Example usage in a MonoBehaviour:
@LotteMakesStuff
LotteMakesStuff / AutohookAttribute.cs
Last active March 19, 2026 13:48
[Autohook] property drawer for unity - Add this [Autohook] attribute to a property to and the inspector will automagically hook up a valid reference for you if it can find a component attached to the same game object that matches the field you put it on. You can watch a demo of this in action here https://youtu.be/faVt09NGzws <3
// NOTE DONT put in an editor folder!
using UnityEngine;
public class AutohookAttribute : PropertyAttribute
{
}
@namkazt
namkazt / Bus.cs
Last active October 9, 2023 10:03
Event Bus for unity with UniRx
// Create by: Nam kazt
// Email: nam.kazt.91@gmail.com
// Event Bus for unity with UniRx
/* How to use:
*
// 1, NormalEventCall
//------------------------------------------------------
// create test passing data
Shader "Custom/SilhouetteShader"
{
Properties
{
_SilhouetteColor("Silhouette Color", Color) = (0,1,0,1)
}
SubShader
{
Tags{"Queue"="Geometry+1" "RenderType" = "Geometry"}
@sinbad
sinbad / SlotArray.cs
Created November 9, 2018 15:27
SlotArray: an array as convenient as a dynamic list but with exposed indexes (similar to using a Dictionary<int,T> but more memory friendly, or an ArrayList which self-manages free slots)
using System;
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// Utility class which stores a dynamic array of objects or value types, and exposes
/// where it places them in its internal storage so you can remove them by index
/// if you need to. Indexes remain stable at all times.
///
/// This is useful for cases like Coroutine where you may not have a reference