Skip to content

Instantly share code, notes, and snippets.

View GhatSmith's full-sized avatar

Ghat Smith GhatSmith

View GitHub Profile
@BlueRyth
BlueRyth / SyncAnimationControllerTool.cs
Last active August 7, 2018 13:53
Unity3D: Sync the Animation window to an Animator without requiring hierarchy selection (4.6.x)
using System;
using System.Reflection;
using UnityEngine;
using UnityEditor;
using UnityEditorInternal;
/// <summary>
/// Class to synchronize the view of the Animator window without requiring hierarchy selection
/// </summary>
class SyncAnimationControllerTool
@Danik
Danik / UnityTweakGUI.cs
Last active August 6, 2021 14:03
A simple in-game parameter tweaking script for Unity. It finds all fields and properties marked with [TweakableMember] in MonoBehaviours in a scene, and enables tweaking in a GUI from inside the game, which can be useful on tablets etc, where there is no access to the inspector.
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
///<summary>
/// A simple in-game GUI for Unity that allows tweaking of script fields
/// and properties marked with [TweakableMember]
///</summary>
@cosmogonies
cosmogonies / PrefabApplyCallback.cs
Last active March 8, 2022 14:36
Callback on Apply Prefab (Unity)
using UnityEngine;
using UnityEditor;
[InitializeOnLoad]
internal class PrefabExtension
{
static PrefabExtension()
{
UnityEditor.PrefabUtility.prefabInstanceUpdated += OnPrefabInstanceUpdate;
}
@MattRix
MattRix / FGInspectorManager.cs
Created March 23, 2016 14:13
A crazy thing that lets you rebind which inspectors are used for which objects at any time (ex. on selection change)
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System;
using System.Linq;
using System.Reflection;
using InspectorPair = FGInspectorReflector.InspectorPair;
@radiatoryang
radiatoryang / SkinnedMeshObjectPreviewExample.cs
Last active October 7, 2022 10:07
An example of a custom ObjectPreview rendering out a SkinnedMesh for Unity Editor C#... I used it for facial expressions and blendshape editing, you might want to use it for something else. I hereby place it under MIT License. Full write-up here: http://www.blog.radiator.debacle.us/2016/06/working-with-custom-objectpreviews-and.html
using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
[CustomPreview(typeof(YourCustomScriptableObject))] // THIS IS VERY IMPORTANT, this is so the editor knows what this is supposed to be previewing at all
public class SkinnedMeshObjectPreviewExample : ObjectPreview {
PreviewRenderUtility m_PreviewUtility;
@Farfarer
Farfarer / Cable.cs
Created July 5, 2016 15:45
Catenary curves in Unity. Creates a catenary curve between two points with a given amount of slack. http://farfarer.com/temp/unity_cables.png
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.EventSystems;
[System.Serializable]
public class CableCurve {
[SerializeField]
Vector3 m_start;
@PopupAsylum
PopupAsylum / PreviewCulling.cs
Created September 23, 2016 08:45
When attached to a Camera, shows that cameras frustum culling in the scene view
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
using System.Collections;
[ExecuteInEditMode]
public class PreviewCulling : MonoBehaviour {
#if UNITY_EDITOR
@jupdike
jupdike / IntersectTwoCircles.js
Last active April 19, 2024 06:13
Find the intersections (two points) of two circles, if they intersect at all
// based on the math here:
// http://math.stackexchange.com/a/1367732
// x1,y1 is the center of the first circle, with radius r1
// x2,y2 is the center of the second ricle, with radius r2
function intersectTwoCircles(x1,y1,r1, x2,y2,r2) {
var centerdx = x1 - x2;
var centerdy = y1 - y2;
var R = Math.sqrt(centerdx * centerdx + centerdy * centerdy);
if (!(Math.abs(r1 - r2) <= R && R <= r1 + r2)) { // no intersection
@PopupAsylum
PopupAsylum / CustomFramer.cs
Created January 24, 2017 11:41
Change how unity's 'F' framing is applied
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class CustomFramer : MonoBehaviour {
public float radius = 1f;
@Thundernerd
Thundernerd / Docker.cs
Last active January 24, 2024 09:32
Helper to dock EditorWindows
#if UNITY_EDITOR
using System;
using System.Reflection;
using UnityEditor;
using UnityEngine;
public static class Docker
{
#region Reflection Types