Skip to content

Instantly share code, notes, and snippets.

View BrianOstrander's full-sized avatar

Brian Ostrander BrianOstrander

View GitHub Profile
@liquidev
liquidev / class.md
Last active April 30, 2024 16:24
My attempt at explaining how to implement classes in Lua

If you're reading this document, you're probably one of many people confused about how to implement OOP-like classes in Lua. But no worries! This document aims to explain all the fundamental concepts in beginner-friendly language.

Metatables

Before we start, we need to talk about metatables. These are Lua's way of allowing users to overload operators. Operators include arithmetic +, -, *, /, etc., but also things like indexing tables a[b], creating new indices in tables a[b] = c, function calls, a(b, c, d), you get the idea.

We can set the metatable of a table using setmetatable(t, metatable). The metatable is another table, that contains fields for overriding

@FlaShG
FlaShG / CanvasPositioningExtensions.cs
Last active July 12, 2024 20:51
A small Unity helper class to convert viewport, screen or world positions to canvas space.
using UnityEngine;
/// <summary>
/// Small helper class to convert viewport, screen or world positions to canvas space.
/// Only works with screen space canvases.
/// </summary>
/// <example>
/// <code>
/// objectOnCanvasRectTransform.anchoredPosition = specificCanvas.WorldToCanvasPoint(worldspaceTransform.position);
/// </code>
@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)
{
@Geri-Borbas
Geri-Borbas / SaveEditorDefaultResources.cs
Last active March 23, 2020 09:46
Snippet to export Unity Editor Assets for inspection. Read more at http://eppz.eu/blog/unity-editor-icon-assets/
//
// Copyright (c) 2017 eppz! mobile, Gergely Borbás (SP)
//
// http://www.twitter.com/_eppz
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
@staltz
staltz / introrx.md
Last active July 22, 2024 09:31
The introduction to Reactive Programming you've been missing