Skip to content

Instantly share code, notes, and snippets.

@hdlx
hdlx / getClosestVertex.py
Last active September 11, 2024 19:04
Maya get closest vertex
import maya.api.OpenMaya as om
import maya.cmds as cmds
#returns the closest vertex given a mesh and a position [x,y,z] in world space.
#Uses om.MfnMesh.getClosestPoint() returned face ID and iterates through face's vertices.
def getClosestVertex(mayaMesh,pos=[0,0,0]):
mVector = om.MVector(pos)#using MVector type to represent position
selectionList = om.MSelectionList()
selectionList.add(mayaMesh)
dPath= selectionList.getDagPath(0)
@phi-lira
phi-lira / UniversalPipelineTemplateShader.shader
Last active October 21, 2025 16:44
Template shader to use as guide to create Universal Pipeline ready shaders. This shader works with Universal Render Pipeline 7.1.x and above.
// When creating shaders for Universal Render Pipeline you can you the ShaderGraph which is super AWESOME!
// However, if you want to author shaders in shading language you can use this teamplate as a base.
// Please note, this shader does not necessarily match perfomance of the built-in URP Lit shader.
// This shader works with URP 7.1.x and above
Shader "Universal Render Pipeline/Custom/Physically Based Example"
{
Properties
{
// Specular vs Metallic workflow
[HideInInspector] _WorkflowMode("WorkflowMode", Float) = 1.0
@jean-moreno
jean-moreno / TextureCombiner.cs
Last active June 16, 2024 11:38
Texture Combiner utility for Unity: create an RGBA texture from 4 different input textures (note: place both files in an Editor folder)
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
public class TextureCombiner : EditorWindow
{
[MenuItem("Tools/Texture Combiner...")]
static void Open()
{
var w = GetWindow<TextureCombiner>(true, "Texture Combiner");
@romainPechot
romainPechot / InspectorButtonAttribute.cs
Created December 6, 2016 17:09
Custom Tweak Propertie Attribute Add Button to Inspector w/out complete CustomInspector (put InspectorButtonPropertyDrawer.cs inside an Editor folder)
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
// format from this thread : https://www.reddit.com/r/Unity3D/comments/1s6czv/inspectorbutton_add_a_custom_button_to_your/
[System.AttributeUsage(System.AttributeTargets.Field)]
public class InspectorButtonAttribute : PropertyAttribute
{
/// <summary>
/// This tool helps to identify and remove empty folders from your Unity 3D project.
///
/// /// Why do I need this:
/// Empty folders are not committed by git but the connected meta files are.
/// So there will be a creation - deletion cycle between between person with and without such a folder.
///
/// /// Usage:
/// The tool adds a new menu Tools->Empty Folder Tool.
/// 1. If you "Toggle Auto Delete", every time you remove or move something in your project

#Quixel Megascans Scripting Reference ###Updated: Aug 19th, 2016

The Megascans Bridge allows the user to send assets from the Bridge to external applications. The Bridge currently supports the following tools:

  • 3DS Max
  • Marmoset Toolbag 2
  • Unity 3d
  • Unreal Engine 4
@nemotoo
nemotoo / .gitattributes
Last active November 7, 2025 05:46
.gitattributes for Unity3D with git-lfs
## Unity ##
*.cs diff=csharp text
*.cginc text
*.shader text
*.mat merge=unityyamlmerge eol=lf
*.anim merge=unityyamlmerge eol=lf
*.unity merge=unityyamlmerge eol=lf
*.prefab merge=unityyamlmerge eol=lf
@nemotoo
nemotoo / .gitignore
Created April 13, 2016 04:29
.gitignore for Unity3D
# ============ #
# OS generated #
# ============ #
.DS_Store*
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
[Tt]humbs.db
@longtimeago
longtimeago / squash-commits.md
Last active April 1, 2024 20:44
How to squash commits in a GitHub pull request

How to squash commits in a GitHub pull request

o you've contributed some code to an open source project, say, Rails. And they'd like you to squash all of the commits in your pull request. But you're not a git wizard; how do you make this happen?

Normally, you'd do something like this. I'm assuming upstream is a git remote that is pointing at the official project repository, and that your changes are in your 'omgpull' branch:

@romainPechot
romainPechot / MenuItemTransformHierarchyFindPath.cs
Created March 13, 2016 16:04
MenuItem for quick copy/paste a Transform hierarchy inside a Unity Scene
using UnityEngine;
using UnityEditor;
public static class MenuItemTransformHierarchyFindPath
{
[MenuItem("CONTEXT/Transform/Copy Transform Path")]
private static void CopySelectionPath(MenuCommand cmd)
{
if(cmd.context)
{