Skip to content

Instantly share code, notes, and snippets.

# RegEx to select EVERY OTHER comma
([^,]*,[^,]*),([^,]*,[^,]*),
@lindazhanghf
lindazhanghf / .zshrc
Last active July 25, 2022 20:42
Customize zsh prompt based on color scheme of Git Bash
# Load version control information
autoload -Uz vcs_info
precmd() { vcs_info }
# Format the vcs_info_msg_0_ variable
zstyle ":vcs_info:git:*" formats "(%b) "
NEWLINE=$'\n'
# Set up the prompt (with git branch name)
setopt PROMPT_SUBST
@lindazhanghf
lindazhanghf / launch.json
Created November 1, 2021 21:07
VS Code debug Unity Editor settings - launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Unity Editor",
"type": "unity",
"path": "/D:/PATH_TO_UNITY_PROJECT/Library/EditorInstance.json",
@lindazhanghf
lindazhanghf / TreeModelEditor.cs
Last active January 23, 2020 22:33
[Unity Game Engine] Editor script for creating prefabs and applying textures to FBX models (materials extracted to the same folder)
using UnityEngine;
using UnityEditor;
public class TreeModelEditor : MonoBehaviour
{
/// Example editor function for creating a new prefab in Assets folder
[MenuItem("GameObject/CreatePrefab")]
public static void CreatePrefab()
{
GameObject newObj = new GameObject();
@lindazhanghf
lindazhanghf / ReadFbx.cs
Last active November 6, 2019 17:16
[Unity Game Engine] Read from an .fbx file with multiple sub-meshes, save as two arrays of meshes and materials, and use Hashtable for indexing
Object[] fbxObjects = Resources.LoadAll("Buildings"); // filename is "Buildings.FBX"
List<Mesh> meshes = new List<Mesh>();
List<Material> materials = new List<Material>();
foreach (Object obj in fbxObjects)
{
if (obj is Mesh)
{
meshes.Add(obj as Mesh);
}
else if (obj is Material)