Skip to content

Instantly share code, notes, and snippets.

View darbotron's full-sized avatar

Alex "darbotron" Darby darbotron

View GitHub Profile
@darbotron
darbotron / UnityObjectId.cs
Created June 19, 2026 11:25
UnityObjectId - wrapper to smooth over migration from int UnityEngine.Object.GetInstanceId() to the EntityId UnityEngine.Object.GetEntityId()
//////////////////////////////////////////////////////////////////////////////
// This source file is part of the "Darbotron Common" UPM Package
//
// File content © 2026 Darbotron Ltd
//
// Licensed under the MIT license: https://opensource.org/license/mit
//////////////////////////////////////////////////////////////////////////////
//#define FORCE_USE_ENTITY_ID
using System;
@darbotron
darbotron / CloneTimelineToPlayableGraph.cs
Last active December 16, 2024 10:10
How to create a PlayableGraph from a TimelineAsset whilst copying over all the bindings from a PlayableDirector
///////////////////////////////////////////////////////////////////////////////
// License: https://opensource.org/licenses/unlicense
//
// TL;DR:
// 1) you may do what you like with it...
// 2) ...except blame me for any consequence of acting on rule 1)
//
///////////////////////////////////////////////////////////////////////////////
using System.Collections.Generic;
//
// StandaloneBuildCompilationChecker by Alex 'darbotron' Darby
//
// License: https://opensource.org/licenses/unlicense
// TL;DR:
// 1) you may do what you like with it...
// 2) ...except blame me for any consequence of acting on rule 1)
//
#if UNITY_EDITOR
@darbotron
darbotron / ExampleSettings.cs
Last active June 6, 2022 09:11
Super easily (and extensibly) add a project global settings asset to the Unity Editor's project settings panels and/or edit in a floating window
//
// GenericUnityEditorSettings by Alex 'darbotron' Darby
//
// License: https://opensource.org/licenses/unlicense
// TL;DR:
// 1) you may do what you like with it...
// 2) ...except blame me for any consequence of acting on rule 1)
//
using UnityEngine;
using UnityEditor;
@darbotron
darbotron / gist:296017d6dce649fee3ed732ec3d77be2
Last active March 3, 2022 19:20
StoppableCoroutine et al. - a bunch of handy classes for managing coroutines in Unity
//
// License: https://opensource.org/licenses/unlicense
// TL;DR:
// 1) you may do what you like with it...
// 2) ...except blame me for any consequence of acting on rule 1)
//
using System;
using System.Collections;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TargetingCamera : MonoBehaviour
{
[SerializeField] Transform m_Horizontal = null;
[SerializeField] Transform m_Vertical = null;
[SerializeField] Transform m_Target = null;
@darbotron
darbotron / gist:cfedbc33fa28d07977969da9ae73656d
Created November 28, 2019 09:07
C/C++ Low Level Curriculum - Part 2 - Simple Program
int AddOneTo( int iParameter )
{
int iLocal = iParameter + 1;
return iLocal;
}
int main( int argc, char** argv )
{
int iResult = 0;
iResult = AddOneTo( iResult );