Skip to content

Instantly share code, notes, and snippets.

View LumosX's full-sized avatar

Lumos LumosX

View GitHub Profile
@LumosX
LumosX / xNodeDynamicListParsing.cs
Last active September 18, 2023 12:39
Helper functions for parsing dynamic list ports in the xNode open-source node editing framework for Unity.
// Example output ports and how we can use them:
[Output(dynamicPortList = true)]
public string[] stringOutputs;
[Output(dynamicPortList = true)]
public float[] floatOutputs;
public override object GetValue(NodePort port) {
// Boilerplate reduction: instead of parsing ports manually every single time, just "expose" a function for the index, if it matches
// You can even chain them with null coalescing in order to not check subsequent fields after one is found
@LumosX
LumosX / Texture2DArrayTools.cs
Last active July 6, 2022 21:33
A fully-functional "editor extension" for Unity that provides the ability to merge textures into Texture2DArrays, or to extract textures from them. (https://docs.unity3d.com/ScriptReference/Texture2DArray.html)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEditor;