Skip to content

Instantly share code, notes, and snippets.

@aholkner
aholkner / InstallUnity.cmd
Last active February 8, 2023 09:06
PowerShell script to install correct version of Unity for a project
@echo off
title Install Unity
echo Just a moment...
powershell -NoProfile -NoLogo -ExecutionPolicy Unrestricted -File PowershellScripts\InstallUnity.ps1 -Project . -Components Windows
pause
using System;
using System.Reflection;
using UnityEngine;
/// Access Unity.Recorder window through reflection
public static class RecordingExtensions
{
/// Start recording video using settings from the Recorder window
public static void StartRecording() => StartStopRecording("StartRecording");
@aholkner
aholkner / ScenesMenuBuild.cs
Last active April 29, 2021 11:58
Unity editor extension to allow for quick scene switching from menu
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
/// Add a `Scenes` menu to Unity editor for quick access to all scenes in project.
///
@aholkner
aholkner / SerializedPropertyExtensions.cs
Last active July 17, 2023 13:58
Unity editor extension providing value get/set methods for SerializedProperty. This simplifies writing PropertyDrawers against non-trivial objects.
/* MIT License
Copyright (c) 2022 Alex Holkner
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@aholkner
aholkner / AnimatorControllerChangeDetector.cs
Last active March 8, 2019 23:13
Unity editor script that warns the user when an AnimatorController asset changes on disk.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
// Detect when .controller assets are modified on disk, and give the user a warning so they
// can restart Unity to pick up the changes.
//
// Workaround for bug #1133706 (AnimatorController assets are not reimported if they contain
// attached StateMachineBehaviour).
@aholkner
aholkner / SceneViewUIOverlay.cs
Last active August 11, 2022 06:29
Unity editor extension to display a zoom indicator over the 2D scene view. Click it to reset to 100% zoom.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System;
// Display a zoom indicator overlay on the 2D scene view. Click it to reset to 100% zoom
[InitializeOnLoad]
public static class SceneViewUIOverlay
{
@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