Skip to content

Instantly share code, notes, and snippets.

@keless
keless / gist:8727613
Created January 31, 2014 06:51
C# EventDispatcher (AS3 style) implementation
//TODO: determine if C# delegates cause reference counting on target object
public delegate void EventDispatcherDelegate( object evtData );
public interface IEventDispatcher
{
void addListener (string evtName, EventDispatcherDelegate callback);
void dropListener (string evtName, EventDispatcherDelegate callback);
void dispatch (string evtName, object evt) ;
}
@chiepomme
chiepomme / Signal.cs
Last active September 13, 2017 08:18
Unity で使えるシグナルを作りたかった
using System;
using System.Collections.Generic;
using UnityEngine;
public interface ISignal
{
void UnsafeSubscribe(Delegate slot, SlotGroup group = null);
void UnsafeUnsubscribe(Delegate slot, SlotGroup group = null);
}
@winkels
winkels / TimeScaleIndependentParticleSystem.cs
Last active March 25, 2018 10:46
Unity script that allows for particle motion while Time.timeScale = 0. See http://www.asteroidbase.com/?p=569 for context.
using UnityEngine;
using System.Collections;
public class TimeScaleIndependentParticleSystem : TimeScaleIndependentUpdate
{
protected override void Update()
{
base.Update();
particleSystem.Simulate(deltaTime, true, false);
@benblo
benblo / EditorCoroutine.cs
Created April 15, 2014 13:26
EditorCoroutine: coroutines for Unity editor operations. Usage: EditorCoroutine.start(myIEnumerator)
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
namespace Swing.Editor
{
public class EditorCoroutine
@fenbf
fenbf / BasicParticles.cpp
Created April 27, 2014 05:47
Basic Particle classes design. Used as a starting point for my particle system. More details http://www.bfilipek.com
#include "particles.h"
#include <assert.h>
#include <algorithm>
namespace particles
{
void ParticleData::generate(size_t maxSize)
{
m_count = maxSize;
m_countAlive = 0;
@tiagosr
tiagosr / SplineSection.cs
Created April 28, 2014 03:22
Hermite Spline for Unity3D
using UnityEngine;
using System.Collections;
public class SplineSection : MonoBehaviour {
public Transform startPoint, startTangent, endPoint, endTangent;
public SplineSection prev, next;
public Vector3 GetPositionAt(float t) {
@staltz
staltz / introrx.md
Last active July 28, 2025 11:58
The introduction to Reactive Programming you've been missing
@JakubNei
JakubNei / Occlusion.Area.cs
Last active April 28, 2025 13:03
Lame Implementation of Area and Portal Occlusion Culling based on DOOM 3 BFG http://www.iddevnet.com/doom3/visportals.php https://github.com/id-Software/DOOM-3-BFG
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Extensions;
namespace Occlusion
{
public class Area : MonoBehaviour
{
@NightOwl888
NightOwl888 / BitSet.cs
Last active July 3, 2025 04:51
C# port of the java.util.BitSet class
/* BitSet.cs -- A vector of bits.
Copyright (C) 1998, 1999, 2000, 2001, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
@jimfleming
jimfleming / GrabScreenSwatch.cs
Created December 7, 2014 06:50
Uses an internal Unity3D utility function to grab chunks of the screen for blurring.
public static class GrabScreenSwatch {
public static Texture GrabScreenSwatch(Rect rect) {
int width = (int)rect.width;
int height = (int)rect.height;
int x = (int)rect.x;
int y = (int)rect.y;
Vector2 position = new Vector2(x, y);
Color[] pixels = UnityEditorInternal.InternalEditorUtility.ReadScreenPixel(position, width, height);