Skip to content

Instantly share code, notes, and snippets.

View bartwttewaall's full-sized avatar

Bart Wttewaall bartwttewaall

View GitHub Profile
@bartwttewaall
bartwttewaall / Unity3D_MinimapComponent.cs
Created July 22, 2019 07:22
A clickable minimap that places a pointer sprite at the position where you clicked and returns a Vector2 with a range of -1 to 1 in both dimensions
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using Wirelab.Pages;
public class MinimapComponent : BaseComponent, IPointerClickHandler {
public GameObject pointerPrefab;
public DataEvent<Vector2> onClick;
@bartwttewaall
bartwttewaall / Unity3D_ScrollRect.md
Last active July 22, 2019 07:11
Unity3D ScrollRect flexible layout recipe

ScrollRect Layout recipe

Used for creating a scrollable list of items, such as a chat panel.

  • Create a new ScrollRect component
  • Navigate to its Content child
  • Add a VerticalLayout component
    • set Child Controls Sizewidth: true, height: true
    • set Child Force Expandwidth: false, height: false
    • set the padding / spacing to whatever you like
  • Add a ContentSizeFitter
@bartwttewaall
bartwttewaall / twig-extentions_meta.ts
Last active July 22, 2019 07:11
Generate HTML meta tags from JSON data (Twig)
import { extendFunction } from "twig";
/**
* Method for building meta tags. Insprited by:
* @link https://gist.github.com/rquast/a9cbc0551a48d10e83b2ad899b293c77
*
* @example js preperation
const meta = {
page: {
description:
@bartwttewaall
bartwttewaall / 2DArraySingleForLoop.js
Last active July 22, 2019 09:32
Traverse a 2d array in single for-loop
function traverse (values, numCols) {
var numRows = values.length / numCols;
for (var i = 0, length = values.length; i < length; i++) {
var row = (i % length / numCols) << 0; // = Math.floor
var col = i % numCols;
console.log(i, row, col);
}
}