Skip to content

Instantly share code, notes, and snippets.

@bengsfort
bengsfort / watch-dev.js
Created April 2, 2020 11:45
Client + Server watching/rebuilding with rollup
const loadConfigFile = require('rollup/dist/loadConfigFile');
const rollup = require('rollup');
const fs = require('fs');
const fsPromises = fs.promises;
const path = require('path');
const child = require('child_process');
const NOOP = () => {};
using System;
using UnityEditor;
using UnityEngine;
namespace Pixeland.Tools.Router.Editor
{
public abstract class EditorBase : UnityEditor.Editor
{
protected void ChangeCheck<T>(T val, Action<T> onChanged) where T : class
{
@bengsfort
bengsfort / convert-fbx-gltf.js
Last active April 17, 2020 19:56
node.js script that converts all `.fbx` assets within a directory to the `.gltf` file format. Requires FBX2glTF (https://github.com/facebookincubator/FBX2glTF) and fs-extra (https://github.com/jprichardson/node-fs-extra). Assumes usage of a module bundler that allows for importing files for use in JS (such as Webpack or Rollup).
/**
* Converts all .fbx files in the provided folder to .gltf files.
* @param {String} src
* @param {String} dest
*/
const spawn = require('child_process').spawn;
const fs = require('fs-extra');
const path = require('path');
@bengsfort
bengsfort / ComponentTemplate.cs.tmpl
Last active July 31, 2017 12:04
Entity-Component-System Helper Window for easy creation of files http://bengsfort.github.io/dev-logs/down-the-ecs-rabbit-hole/
// {0}
// Created by {1} @ {2:d}
using System;
using FlyingIsHard.Assets.Bengsfort.Components.Core;
namespace FlyingIsHard.Assets.Bengsfort.Components
{{
[Serializable]
public class {0} : BaseComponent
{{
@bengsfort
bengsfort / SectionEndComponent.cs
Last active July 6, 2017 03:50
Full implementation of an animated section end trigger using ECS
using System;
using Bengsfort.Components.Core;
using UnityEngine;
namespace Bengsfort.Components
{
// This component handles the visual rendering of the section end component.
[Serializable]
public class SectionEndComponent : BaseComponent
{
@bengsfort
bengsfort / PlayerComponent.cs
Created July 5, 2017 19:37
example of bare bones ECS implementation with MonoBehaviours
// PlayerComponent
using System;
using UnityEngine;
using Bengsfort.Components.Core;
namespace Bengsfort.Components
{
[Serializable]
public class PlayerComponent : BaseComponent
@bengsfort
bengsfort / TouchController.cs
Last active July 11, 2017 12:54
A template for basic single-touch handling in Unity.
using UnityEngine;
public class TouchController : MonoBehaviour
{
int _activeFinger = -1;
void Update ()
{
ReadTouches();
}
@bengsfort
bengsfort / .gitignore
Last active October 12, 2017 03:26
Unity project .gitignore
# Unity folders
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/Assets/AssetStoreTools*
# Visual Studio 2015 cache directory
/.vs/
@bengsfort
bengsfort / buildAppsObject.filter.js
Created March 24, 2015 17:00
Directory filtering to omit dotfiles
// Using Array#filter to create array without any dotfiles
var fs = require('fs');
var handlebars = require('handlebars');
module.exports = function(){
var appsArray = fs.readdirSync('apps').filter(function(dir) {
// return true if `dir` does not start with a `.`
// to avoid dotfiles causing ENOTDIR (not a directory) errors