yum/3ner
A toon shader for Unity's BIRP.
git clone https://git.yummers.dev/yum/3ner
2b9c5ca
master
1// Source: https://gist.githubusercontent.com/s-ilent/067d4e477041d52d2f8eabd78927d1a4/raw/568c222044a8ce3c33426c495cccbfe7c3a0c733/LinuxTabFix.cs 2#ifUNITY_EDITOR 3using UnityEditor ; 4using UnityEngine ; 5using UnityEngine . UIElements ; 6using System ; 7using System . Collections . Generic ; 8using System . Runtime . CompilerServices ; 9 10/// <summary> 11/// Linux Editor Tab Navigation Patch for Unity (2022.3+, Unity 6). 12/// Restores missing ASCII '\t' character codes stripped by Linux window backend 13/// and manages focus handshakes between IMGUIContainers in UI Toolkit windows. 14/// </summary> 15[ InitializeOnLoad ] 16public static class LinuxTabFix 17{ 18private static readonly ConditionalWeakTable < IMGUIContainer , object > patchedContainers 19= new ConditionalWeakTable < IMGUIContainer , object > (); 20 21static LinuxTabFix () 22{ 23// Ensure idempotent event subscription across domain reloads 24EditorApplication . update -= ApplyTabPatchToFocusedWindow ; 25EditorApplication . update += ApplyTabPatchToFocusedWindow ; 26} 27 28private static void ApplyTabPatchToFocusedWindow () 29{ 30EditorWindow focusedWindow = EditorWindow . focusedWindow ; 31if ( focusedWindow == null ) return ; 32 33VisualElement root = focusedWindow . rootVisualElement ; 34if ( root == null ) return ; 35 36List < IMGUIContainer > containers = root . Query < IMGUIContainer > (). ToList (); 37int count = containers . Count ; 38 39for ( int i = 0 ; i < count ; i ++ ) 40{ 41IMGUIContainer container = containers [ i ]; 42if ( container == null ) continue ; 43 44int currentIndex = i ; 45 46// Patch unhandled containers without modifying container properties 47if ( ! patchedContainers . TryGetValue ( container , out _ )) 48{ 49patchedContainers . Add ( container , null ); 50Action originalHandler = container . onGUIHandler ; 51 52container . onGUIHandler = () => 53{ 54Event e = Event . current ; 55 56if ( e != null && e . type == EventType . KeyDown && e . keyCode == KeyCode . Tab ) 57{ 58// Restore character code stripped by Linux native window backend 59if ( e . character == 0 ) 60{ 61e . character = '\t' ; 62} 63 64bool isShift = e . shift ; 65 66// Execute original IMGUI pass 67originalHandler ? . Invoke (); 68 69// When boundary is reached, transfer focus to adjacent container 70if ( GUIUtility . keyboardControl == 0 ) 71{ 72int targetIndex = isShift ? currentIndex - 1 : currentIndex + 1 ; 73 74if ( targetIndex >= 0 && targetIndex < count && targetIndex < containers . Count ) 75{ 76IMGUIContainer targetContainer = containers [ targetIndex ]; 77if ( targetContainer != null ) 78{ 79targetContainer . Focus (); 80focusedWindow . Repaint (); 81} 82} 83} 84 85return ; 86} 87 88originalHandler ? . Invoke (); 89}; 90} 91} 92} 93} 94#endif