Skip to content

Instantly share code, notes, and snippets.

View GhatSmith's full-sized avatar

Ghat Smith GhatSmith

View GitHub Profile
@joshcamas
joshcamas / DisableSelectAllOnFocus.cs
Last active September 7, 2019 13:55
Disabling annoying "select all on focus" for EditorUI.TextArea
//Just set EditorGUI.s_SelectAllOnMouseUp (an internal variable) to false every frame / every time you draw.
//This variable is usually set to true in certain circumstances, so we're overwriting the value.
//I honestly don't know why this feature exists, it's quite annoying and never useful.
//Of course, be sure to cache the field!
selectAllField = typeof(EditorGUI).GetField("s_SelectAllOnMouseUp", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Default);
selectAllField.SetValue(null, false);
@SimonDarksideJ
SimonDarksideJ / GetButtonsDown.cs
Created June 5, 2019 10:18
Simple script used to identify the Unity inputs from a controller (where documentation lets you down)
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GetButtonsDown : MonoBehaviour
{
string[] joysticks;
int joysticksCount = 0;
// Start is called before the first frame update
@aholkner
aholkner / CreatePrefabAssetEditorMenu.cs
Last active June 11, 2022 11:37
Unity editor extension to create prefabs from asset menu
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEditor;
using UnityEditor.Experimental;
using UnityEditor.ProjectWindowCallback;
// Add "New Prefab" asset creation menu items.
public static class CreatePrefabAssetEditorMenu
@karljj1
karljj1 / Unity Assembly Definition Debugger.cs
Last active April 2, 2025 23:06
Find out what assemblies are being built and how long each takes.
using System;
using System.Collections.Generic;
using System.Text;
using UnityEditor;
using UnityEditor.Compilation;
using UnityEngine;
[InitializeOnLoad]
public class AsmdefDebug
{
@LotteMakesStuff
LotteMakesStuff / NativeMeshTest.cs
Created August 8, 2018 00:30
[NativeCollections] How to copy a regular .C# array into a NativeArray suuuuuper quick using memcpy. its about as fast as its ever gunna get!
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Mathematics;
using UnityEngine;
public class NativeMeshTest : MonoBehaviour
{
private NativeArray<float3> vertexBuffer;
private Vector3[] vertexArray;
@rstecca
rstecca / MakeA3DObjectDraggable.cs
Last active September 29, 2021 11:32
How to make a 3D object draggable in Unity3D
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
/*
MAKE A 3D OBJECT DRAGGABLE
Riccardo Stecca
http://www.riccardostecca.net
using UnityEditor;
using UnityEngine;
namespace Utils {
public class ScriptTemplateModifier : UnityEditor.AssetModificationProcessor {
private const string SCRIPT_LOCATION = "Assets/Scripts/";
private const string PROJECT_NAME = "#PROJECT_NAME#";
private const string FILE_PATH = "#FILE_PATH#";
@LotteMakesStuff
LotteMakesStuff / PlayerLoop.cs
Last active September 24, 2024 06:38
Player Loop Visualizer: Built to explore the new PlayerLoopSystem api in Unity 2018.1b2. This tool shows you all the PlayerLoop systems that unity uses to update a frame, and demos how to add your own and even remove systems from the player loop. For more info see the patreon post https://www.patreon.com/posts/unity-2018-1-16336053
// Put this in an editor folder
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.Experimental.LowLevel;
using UnityEngine.Profiling;
@tomkail
tomkail / DefaultAssetEditor.cs
Last active August 21, 2024 10:41
Draws inspectors for any file type Unity doesn't draw by default
/// Used to draw custom inspectors for unrecognised file types, which Unity imports as "DefaultAsset"
/// To do this, create a new editor class extending DefaultAssetInspector
/// Return true in the IsValid function if the file extension of the file matches the type you'd like to draw.
/// The DefaultAssetEditor class will then hold a reference to the new instance of your editor class and call the appropriate methods for drawing.
/// An example can be found at the bottom of the file.
using UnityEngine;
using UnityEditor;
using System;
using System.IO;
@rus89
rus89 / .gitignore
Last active September 2, 2018 18:42
.gitignore sample for Unity, Monodevelop, VisualStudio, VisualStudioCode on OSX, Windows and Linux OS, thanks to: http://midva.games/, https://play.google.com/store/apps/developer?id=Midva.Games
# Created by https://www.gitignore.io/api/osx,linux,unity,csharp,windows,monodevelop,visualstudio,visualstudiocode
### Csharp ###
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files