Skip to content

Instantly share code, notes, and snippets.

View gekidoslair's full-sized avatar
💭
Surfin the Chaos

Mike Wuetherick gekidoslair

💭
Surfin the Chaos
View GitHub Profile
@gekidoslair
gekidoslair / CharacterMeshBind.cs
Last active April 14, 2020 11:30
Bind clothing mesh to a parent character skin / rig
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace PixelWizards.CharacterCustomizer
{
/// <summary>
/// attach this to the clothing GO you want to attach (the GO with the SkinnedMeshRenderer)
/// drag the main character body you want to attach it to (the GO with the SkinnedMeshRenderer)
/// the clothing rig must have been the same rig the character's body used. the body parts (transforms) must be named the same thing
@gekidoslair
gekidoslair / ResetParentTransform.cs
Created November 10, 2019 01:07
Quick utility to reset a parent GameObject position to 0,0,0 without screwing up the child positions
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace MWU.Shared.Utilities
{
public static class ResetParentTransform
{
[MenuItem("Tools/Edit/Reset Parent Transform %_r")]
public static void DistributeObjectsEvenly()
@gekidoslair
gekidoslair / CreateEmptyAtRoot.cs
Created November 10, 2019 17:13
Adds 'Create Empty at Root' shortcut for the GameObject / right-click context menu to create an empty gameobject at 0,0,0
using UnityEditor;
using UnityEngine;
namespace MWU.Shared.Utilities
{
public class CreateEmptyAtRoot : MonoBehaviour
{
[MenuItem("GameObject/Create Empty at Root", false, 0)]
public static void Create()
@gekidoslair
gekidoslair / DistributeEvenly.cs
Last active January 26, 2020 12:18
Distribute GameObjects in a scene evenly (along x, y or z axis)
using UnityEngine;
using UnityEditor;
using UnityEditor.ShortcutManagement;
namespace PixelWizards.Utilities
{
// This causes the class' static constructor to be called on load and on starting playmode
[InitializeOnLoad]
class PhysicsSettler
@gekidoslair
gekidoslair / PhysicsSettler.cs
Created December 30, 2019 23:58
Activate physics in Edit mode to dynamically drop or settle objects in a scene
using UnityEngine;
using UnityEditor;
using UnityEditor.ShortcutManagement;
namespace PixelWizards.Utilities
{
// This causes the class' static constructor to be called on load and on starting playmode
[InitializeOnLoad]
class PhysicsSettler
@gekidoslair
gekidoslair / textureassign.cs
Created February 18, 2020 01:34
Add textures to a material based on a naming convention
/// <summary>
/// Grab the end of the string for our naming convention and see if it matches a known convention
/// </summary>
/// <param name="texture"></param>
/// <param name="material"></param>
private static void SetTexture(Texture2D texture, Material material)
{
var split = texture.name.Split('_');
var idx = split.Length - 1;
// Debug.Log("Postfix for texture: " + texture.name + " : " + split[idx]);
@gekidoslair
gekidoslair / TextureProcessor.cs
Last active April 13, 2020 18:30
Batch apply textures to materials
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
[System.Serializable]
public class MaterialEntry
{
public Material material;
public List<Texture2D> textures;
@gekidoslair
gekidoslair / BoneDebug.cs
Created April 13, 2020 23:00
Simple tool that displays all of the bones that a particular mesh is bound to - useful for debugging skin weighting etc
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
public class BoneDebug : MonoBehaviour
{
SkinnedMeshRenderer skm;
public List<Transform> bones = new List<Transform>();
@gekidoslair
gekidoslair / EditorNote.cs
Last active May 30, 2020 16:51
Add to any gameobject to provide scene-view annotations
using UnityEditor;
using UnityEngine;
namespace PixelWizards.Utilities
{
public class EditorNote : MonoBehaviour
{
[TextArea]
public string m_Text;
public Vector3 m_Offset;
@gekidoslair
gekidoslair / photon-pun-cheatsheet.md
Created July 3, 2020 17:51 — forked from ssshake/isWrit
Photon PUN Cheat Sheet

Photon Methods

public class Blank : Photon.PunBehaviour

instead of mono behavior, use this to receive photon callbacks in your script.

public override void OnLeftRoom()

An example of overriding a punbehavior callback