Skip to content

Instantly share code, notes, and snippets.

public interface IEdible
{
void Eat();
}
public interface IOrganic
{
void ApplyDubiousHealthBenefits(Body a);
}
public class PriceyApple : IEdible, IOrganic
@renaudbedard
renaudbedard / gist:3715057
Created September 13, 2012 15:23
JsonFx WFH
// ...
static JsonWriter jsonWriter;
static JsonReader jsonReader;
ReadResponse readResponse;
class ReadResponse
{
public string Message;
@renaudbedard
renaudbedard / EventExtensions.cs
Last active July 8, 2016 03:27
Generic method to hook events to Unity 4.6+ UI EventTriggers
public static class EventExtensions
{
public static void AddEvent<TSource, TEvent>(this EventTrigger _trigger, EventTriggerType _eventType, TSource _source, Action<TSource, TEvent> _delegate)
where TEvent : BaseEventData
{
EventTrigger.TriggerEvent triggerEvent = new EventTrigger.TriggerEvent();
triggerEvent.AddListener(_data => _delegate(_source, _data as TEvent));
_trigger.triggers.Add(new EventTrigger.Entry { eventID = _eventType, callback = triggerEvent });
}
}
using System;
using System.Globalization;
using UnityEngine;
namespace Yarn
{
// A value from inside Yarn.
public struct Value : IComparable, IComparable<Value>, IEquatable<Value>
{
internal readonly Type type;
@renaudbedard
renaudbedard / DrawActionScheduler.cs
Created August 17, 2016 01:17
The load-time GL call scheduler that FEZ 1.12 uses
using System;
using System.Collections.Concurrent;
namespace FezEngine.Tools
{
public static class DrawActionScheduler
{
static readonly ConcurrentQueue<Action> DeferredDrawActions = new ConcurrentQueue<Action>();
public static void Schedule(Action action)
@renaudbedard
renaudbedard / Foo.cs
Created September 2, 2016 14:31
Nested coroutine stop problem
class Foo : MonoBehaviour
{
Coroutine m_coroutine;
public void StartThing()
{
m_coroutine = StartCoroutine(ParentCoroutine());
}
public void EndThing()
@renaudbedard
renaudbedard / Foo.cs
Created September 2, 2016 14:58
El cheapo way to fix the nested stopcoroutine problem
class Foo : MonoBehaviour
{
Coroutine m_coroutine;
readonly HashSet<IEnumerator> m_innerCoroutines = new HashSet<IEnumerator>();
public void StartThing()
{
m_coroutine = StartCoroutine(ParentCoroutine());
}
@renaudbedard
renaudbedard / ActivityLog.xml
Last active March 8, 2017 17:00
VSTU Errors
<entry>
<record>566</record>
<time>2017/03/08 16:55:29.708</time>
<type>Error</type>
<source>Microsoft.VisualStudio.CommonIDE.ExtensibilityHosting.VsShellComponentModelHost</source>
<description>A MEF Component threw an exception at runtime: System.IO.FileLoadException: Could not load file or assembly &apos;SyntaxTree.VisualStudio.Unity, Version=2.8.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&apos; or one of its dependencies. The located assembly&apos;s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)&#x000D;&#x000A;File name: &apos;SyntaxTree.VisualStudio.Unity, Version=2.8.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&apos;&#x000D;&#x000A; at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark&amp; stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)&#x00
@renaudbedard
renaudbedard / gist:71b80bd7d76e4967376c
Created September 17, 2014 04:16
Barely tested Unity "Rich Text" substring tool
struct SubstringInfo
{
public int StartsAt;
public string TagSuffix;
public SubstringInfo(int startsAt, IEnumerable<string> tagSuffixChain)
{
StartsAt = startsAt;
TagSuffix = string.Empty;
foreach (var tagSuffix in tagSuffixChain)
static void SetupDpiAwareness()
{
bool success = false;
List<string> errorCauses = new List<string>();
string successfulMethod = null;
try
{
var result = DpiAwareness.SetProcessDpiAwareness(DpiAwareness.PROCESS_DPI_AWARENESS.PROCESS_PER_MONITOR_DPI_AWARE);
if (result == DpiAwareness.HRESULT.E_ACCESSDENIED)
{