Skip to content

Instantly share code, notes, and snippets.

View GhatSmith's full-sized avatar

Ghat Smith GhatSmith

View GitHub Profile
@GhatSmith
GhatSmith / TransformEditor.cs
Last active April 4, 2023 09:46
Custom inspector for Transform component. Add buttons to reset, copy, paste Transform values. Add context menu to round or truncate values.
using UnityEngine;
using UnityEditor;
namespace OddTales.Framework.Core.EditorExtension
{
/// <summary>
/// Custom inspector for Transform component. Using only DrawDefaultInspector would give different display.
/// Script based on Unity wiki implementation : https://wiki.unity3d.com/index.php/TransformInspector
/// Buttons to reset, copy, paste Transform values.
@GhatSmith
GhatSmith / DebugText.cs
Last active September 2, 2018 15:47 — forked from kkukshtel/DebugText.cs
Add text into your Unity Game/Scene view using only a script. Basically Debug.Log for runtime text.
// Source : https://gist.github.com/kkukshtel/3cec9473bb5eda90635f1765e259498d
// Modifications identified by comment starting with HACK tag
using UnityEngine;
namespace OddTales.Framework.Core.Other
{
public static class DebugText
{
using UnityEditor;
namespace OddTales.Framework.Core.EditorExtension
{
/// <summary> Base class with logic to extend Unity built in inspector </summary>
public class ExtendUnityInspector<T> : Editor
{
/// <summary> Can be overriden for specific cases </summary>
protected virtual System.Type EditorType
@GhatSmith
GhatSmith / gist:b0cd86bb49a8ed74236b7ce0c5bbb370
Last active September 11, 2018 22:20
CopyPasteStateMachineBehaviour
using UnityEngine;
using UnityEditor;
using UnityEditor.Animations;
namespace OddTales.TLN.Animations
{
/// <summary> Add Copy/Paste context menu item for StateMachineBehaviour </summary>
public static class CopyPasteStateMachineBehaviour
{
using UnityEngine;
using System.Collections;
using System;
namespace OddTales.Framework.Core.ClassExtension
{
/// <summary>
/// Invoke methods of MonoBehaviour call other methods by name.
/// Methods called by name is hard to track in code (you cannot find "Usages")
using UnityEngine;
namespace OddTales.Framework.Core.ClassExtension
{
public static class FloatExtension
{
/// <summary>
/// Maps value from original range to new range
/// </summary>
// Based on : http://baba-s.hatenablog.com/entry/2014/07/30/152826
using System;
using System.Linq;
using System.Reflection;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using UnityEditor;
using System.Linq;
using UnityEngine.SceneManagement;
using System.Globalization;
namespace OddTales.Framework.Core.EditorExtension
{
// InitializeOnLoad : force constructor call
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
[InitializeOnLoad]
public static class OrderedSelection
{
// For Objects ordered selection
private static HashSet<Object> objectsSelectionSet = new HashSet<Object>();
@GhatSmith
GhatSmith / AnimatorControllerExtension
Created September 22, 2018 17:07
AnimatorControllerExtension
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using UnityEngine;
using UnityEditor.Animations;
public static class AnimatorControllerExtension
{
private static MethodInfo getEffectiveAnimatorControllerMethodInfo = null;