Skip to content

Instantly share code, notes, and snippets.

View GhatSmith's full-sized avatar

Ghat Smith GhatSmith

View GitHub Profile
@darkon76
darkon76 / AnimatedText
Last active February 19, 2019 09:43
UI Canvas. Animated conversation text.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(Text))]
public class AnimatedText: BaseMeshEffect
{
[SerializeField] private float _waitBetweenLetters = .1f;
private CanvasRenderer _canvasRendered;
@yagero
yagero / ButtonSmartNav.cs
Last active March 18, 2024 06:39
Unity UI ButtonSmartNav
using UnityEngine.UI;
// Use this class instead of Unity's default Button
// to automatically skip disabled and inactive Buttons
// if you define your navigation as explicit
public class ButtonSmartNav : Button
{
bool CanReachSelectable(Selectable select)
{
return !select || (select.interactable && select.gameObject.activeInHierarchy);
@LotteMakesStuff
LotteMakesStuff / EditorCoroutineRunner.cs
Last active August 28, 2024 19:09
Run stuff in the editor with all the convenience of co-routines! Add a status UI super easily to see readouts what your long running code is actually doing! nice~ There is a short API demo at the top of the class. This is a prefect companion for my inspector buttons https://gist.github.com/LotteMakesStuff/dd785ff49b2a5048bb60333a6a125187
using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
public class EditorCoroutineRunner
{
[MenuItem("Window/Lotte's Coroutine Runner: Demo")]
@Thundernerd
Thundernerd / Docker.cs
Last active March 21, 2025 17:28
Helper to dock EditorWindows
#if UNITY_EDITOR
using System;
using System.Reflection;
using UnityEditor;
using UnityEngine;
public static class Docker
{
#region Reflection Types
@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;
@jupdike
jupdike / IntersectTwoCircles.js
Last active April 15, 2025 13:28
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 / 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
@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;
@radiatoryang
radiatoryang / SkinnedMeshObjectPreviewExample.cs
Last active December 27, 2024 06:25
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;
@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;