This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Reflection; | |
using UnityEditor; | |
using UnityEngine; | |
using UnityEngine.UIElements; | |
using Object = UnityEngine.Object; | |
/// <summary><para>Use this class to override a built-in Editor that is not publicly exposed in the API.</para> | |
/// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using UnityEngine; | |
/// <summary>Constrains an AnimationCurve to a specific range. Use the default constructor for the typical 0-1 range. Use Mathf.Infinity to unconstrain specific values.</summary> | |
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = true)] | |
public class ClampedCurveAttribute : PropertyAttribute | |
{ | |
public Rect ranges; | |
public ClampedCurveAttribute() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Share code between HLSL (shaders) and C# | |
// | |
// Limitations: | |
// - Cannot use #include | |
// - Must use defines to hide certain keywords, such as public, private, protected, or any other object-oriented programming keywords | |
// - Use defines to convert half or fixed to your desired C# equivalent | |
// - Must always write f after float literals | |
// - Use #if !MY_DEFINE instead of #ifndef MY_DEFINE | |
// - #define cannot be used with a value in C#, not even inside an '#if SHADER_TARGET' block. Therefore, you have two options for declaring valued constants: | |
// a. Declare each constant separately in HLSL (using 'static const float MyConstant = 1.0f') and in C# (using 'const float MyConstant = 1.0f'). C# does not support 'static const'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
using UnityEditor.ShortcutManagement; | |
using UnityEngine; | |
public class CloseEditorWindowShortcut | |
{ | |
[Shortcut("Window/Close", KeyCode.W, ShortcutModifiers.Control)] | |
private static void CloseTab(ShortcutArguments args) | |
{ | |
if (EditorWindow.focusedWindow != null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.Rendering; | |
using UnityEngine.UI; | |
namespace kraj0t.Rendering | |
{ | |
/// <summary> | |
/// This class is a convenient way of collecting mesh data and avoiding having to constantly query and dirty a Unity mesh, which is BAD for performance. | |
/// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
if not exist *.m4a ( | |
echo This directory contains no m4a files. | |
) else ( | |
for %%f in (*.m4a) do ( | |
:: Option 1. LOOPING VIDEO | |
ffmpeg -i "%%f" -stream_loop -1 -i "loop-360p.mp4" -shortest "%%~nf.mp4" | |
:: Option 2. STATIC BLACK IMAGE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary>Universal method for retrieving the fileId of a component inside a saved gameObject, and the guid to the file that contains the gameObject. | |
/// The gameObject could live in a prefab or in a scene, and the component does not need to be at the root gameObject of the prefab.</summary> | |
/// <param name="comp"></param> | |
/// <returns>A tuple containing the guid and the fileId of the component. Returns null if the component's gameObject has not been saved to a scene or a prefab.</returns> | |
public static Tuple<string, long> GetComponentIdentifiers(Component comp) | |
{ | |
// Check if the component is the direct instance from the prefab. | |
// In the Editor, this means that the prefab asset is selected and the component is showing in the Inspector. | |
if (AssetDatabase.TryGetGUIDAndLocalFileIdentifier(comp, out string guid, out long fileId)) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
using UnityEditor.UI; | |
using UnityEngine; | |
using UnityEngine.UI; | |
[CustomEditor(typeof(Image))] | |
public class CustomImageEditor : ImageEditor | |
{ | |
public override void OnInspectorGUI() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Reflection; | |
using UnityEditor; | |
using UnityEngine; | |
[CustomEditor(typeof(ParticleSystem))] | |
public class CustomParticleSystemEditor : Editor | |
{ | |
private Editor _builtInEditor; | |
private void OnEnable() |
NewerOlder