Skip to content

Instantly share code, notes, and snippets.

using UnityEngine;
using UnityEngine.Timeline;
public class PhysicsSimComponent : MonoBehaviour, ITimeControl
{
private Vector3[] positions, velocitys, angularVelocitys;
private Quaternion[] rotations;
private Rigidbody[] rigidbodys;
@lazlo-bonin
lazlo-bonin / UndoUtility.cs
Last active June 17, 2024 12:51
Fixing Unity's broken Undo.RecordObject
using UnityEditor;
using UnityEngine;
using UnityObject = UnityEngine.Object;
namespace Ludiq
{
public static class UndoUtility
{
private static void RecordObject(UnityObject uo, string name)
{
@patricknelson
patricknelson / Quaternion.shader
Last active April 13, 2025 11:21 — forked from nkint/pointTowards.vertex
Shader functions to facilitate rotation of vertex around point with a quaternion (Unity / HLSL / Cg)
// Full shader example demonstrating how to use a quaterionion to rotate a vertex around a specific point. Note that this is just a plain
// vanilla unlit shader which includes the necessary functions (see section below) and example code in the vertex shader.
//
// Forked from https://gist.github.com/nkint/7449c893fb7d6b5fa83118b8474d7dcb
// Converted from GLSL to Cg. For help with that, see https://alastaira.wordpress.com/2015/08/07/unity-shadertoys-a-k-a-converting-glsl-shaders-to-cghlsl/
//
// quaternion code from https://github.com/stackgl/gl-quat
// rotation from https://twistedpairdevelopment.wordpress.com/2013/02/11/rotating-a-vector-by-a-quaternion-in-glsl/
Shader "Unlit/Quaternion"
@kodai100
kodai100 / Matrix2x2.cs
Last active November 2, 2022 16:45
Matrix2x2 for Unity
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class Matrix2x2 {
public float m00, m01, m10, m11;
@reunono
reunono / CinemachineCameraShaker.cs
Last active January 16, 2023 07:51
Cinemachine camera shake
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// Add this component to your Cinemachine Virtual Camera to have it shake when calling its ShakeCamera methods.
/// </summary>
public class CinemachineCameraShaker : MonoBehaviour
{
@ousttrue
ousttrue / AlphaClip.cs
Last active May 2, 2018 11:57
A custom timeline track for Unity2017.3. File name must be same as class name at clip and track.
using System;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;
public class AlphaBehaviour : PlayableBehaviour
{
public float Alpha;
}

Generating Procedural Game Worlds with Wave Function Collapse

Wave Function Collapse (WFC) by @exutumno is a new algorithm that can generate procedural patterns from a sample image. It's especially exciting for game designers, letting us draw our ideas instead of hand coding them. We'll take a look at the kinds of output WFC can produce and the meaning of the algorithm's parameters. Then we'll walk through setting up WFC in javascript and the Unity game engine.

sprites

The traditional approach to this sort of output is to hand code algorithms that generate features, and combine them to alter your game map. For example you could sprinkle some trees at random coordinates, draw roads with a brownian motion, and add rooms with a Binary Space Partition. This is powerful but time consuming, and your original vision can someti

@tsubaki
tsubaki / Warikomi.cs
Created July 29, 2017 17:59
AnimationControllerのアニメーションに割り込み
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Animations;
public class Warikomi : MonoBehaviour {
PlayableGraph graph;
AnimatorControllerPlayable controllerPlayable;
@tsubaki
tsubaki / SomeAnimations.cs
Last active April 12, 2022 08:54
AnimationClipPlayableを使いまわす
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Animations;
using UnityEngine.Profiling;
public class LoopSomeAnimations : MonoBehaviour
{
[SerializeField] AnimationClip[] clips = null;
@mob-sakai
mob-sakai / CacheableDownloadHandler.cs
Created July 28, 2017 10:04
Etag-cacheable DownloadHandler for Unity.
using UnityEngine.Networking;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using UnityEngine;
using System;
namespace Mobcast.Coffee.AssetSystem
{