Skip to content

Instantly share code, notes, and snippets.

View canxerian's full-sized avatar

Mark Nguyen canxerian

  • Microsoft
View GitHub Profile
@canxerian
canxerian / FlyCamera.cs
Last active January 3, 2023 14:52 — forked from FreyaHolmer/FlyCamera.cs
A camera controller for easily flying around a scene in Unity smoothly. WASD for lateral movement, Space & Ctrl for vertical movement, Shift to move faster. Add this script to an existing camera, or an empty game object, hit play, and you're ready to go~
// https://gist.github.com/FreyaHolmer/650ecd551562352120445513efa1d952
using UnityEngine;
[RequireComponent(typeof(Camera))]
public class FlyCamera : MonoBehaviour
{
public float acceleration = 50; // how fast you accelerate
public float accSprintMultiplier = 4; // how much faster you go when "sprinting"
public float lookSensitivity = 1; // mouse look sensitivity
@canxerian
canxerian / LightEstimation.cs
Created August 14, 2022 08:37
A Unity component for using ARFoundation's Light Estimation feature to modify the main light in our scene
using UnityEngine;
using UnityEngine.XR.ARFoundation;
/// <summary>
/// A Unity component for using ARFoundation's Light Estimation feature to modify
/// the main light in our scene
/// </summary>
public class LightEstimation : MonoBehaviour
{
[SerializeField]
@canxerian
canxerian / ARPlanePlacement.cs
Last active August 13, 2022 21:04
Unity component for placing a target gameobject on a plane. Raycasts from the center of the screen
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARSubsystems;
/// <summary>
/// Component for placing a target gameobject on a plane. Raycasts from the center of the screen.
/// </summary>
public class ARPlanePlacement : MonoBehaviour
{
@canxerian
canxerian / how_to_icons_with_textmeshpro.txt
Last active April 16, 2024 14:29
How to use glyph icons with TextMeshPro
This guide shows how you can you use icon fonts in TextMeshPro
1. Copy the font file (.ttf) and copy it a location inside your Unity assets folder. I found my font file here: ‪C:\Windows\Fonts\SegoeIcons.ttf
2. In Unity, navigate to:
Window > TextMeshPro > Font Asset Creator
Select the font file you just copied to your project in "Source Font File"
3. Find the Unicode representation of your icon, these can be found on this website, for example: https://docs.microsoft.com/en-us/windows/apps/design/style/segoe-ui-symbol-font
Enter this Unicode to in to the text area labelled "Character Sequence (Hex).
@canxerian
canxerian / local_repo_going_remote.sh
Created June 7, 2022 12:12
Make a local git repo remote, i.e track GitHub, GitLab, DevOps etc
# Suppose you've been working on a local repo and now wish to host it on GitHub, GitLab, Azure DevOps etc.
# These git commands will enable you to do so whilst keeping history intact
# 1. Use the GitHub/GitLab/DevOps web interface to create the repo.
# Copy the URL to the repo (https option).
# 2. In your repo, add it as a remote
git remote add origin <REMOTE_URL>
# 3. Push your changes to the remote repo
@canxerian
canxerian / get_primes.py
Created August 23, 2012 00:45
A python function to return primes from 2 to n
def get_primes(n) :
# 2 is the smallest prime. Declaring it here cleans up the algorithm
primes = [2];
# Start calulating primes at 3
prime_count = 3;
while prime_count <= n:
# can it be divided by
to_be_divided_by = prime_count - 1
@canxerian
canxerian / app.js
Created November 21, 2011 01:08 — forked from alessioalex/app.js
From Pedro Teixeira's http://nodetuts.com/tutorials/12-file-uploads-using-nodejs-and-express.html but with connect-form instead of multipart-js
var express = require('express'),
form = require('connect-form'),
fs = require('fs'),
util = require('util');
var app = express.createServer(
form({keepExtensions: true})
);
// switch between development and production like this: