From 5c250f71e43acfc8077d4d0a6f2c6e8b5376ec8b Mon Sep 17 00:00:00 2001 From: Ryan Boyer Date: Tue, 5 Mar 2024 21:56:53 -0700 Subject: [PATCH 1/2] Improvements --- .DS_Store | Bin 6148 -> 0 bytes .gitignore | 2 + Scripts/Editor.meta => Editor.meta | 2 +- Editor/EditorThemeSwitcher.cs | 82 ++++++++++++++++++ .../EditorThemeSwitcher.cs.meta | 0 Editor/NativeColorScheme.Editor.asmdef | 18 ++++ Editor/NativeColorScheme.Editor.asmdef.meta | 7 ++ Scripts.meta => Runtime.meta | 0 Runtime/ColorScheme.cs | 6 ++ {Scripts => Runtime}/ColorScheme.cs.meta | 0 Runtime/ColorSchemeUtil.cs | 29 +++++++ {Scripts => Runtime}/ColorSchemeUtil.cs.meta | 0 {Scripts => Runtime}/ColorScheme_iOS.mm | 0 {Scripts => Runtime}/ColorScheme_iOS.mm.meta | 0 .../ColorScheme_macOS.bundle.meta | 0 .../ColorScheme_macOS.bundle/Contents.meta | 0 .../Contents/Info.plist | 0 .../Contents/Info.plist.meta | 0 .../Contents/MacOS.meta | 0 .../Contents/MacOS/ColorScheme_macOS | Bin .../Contents/MacOS/ColorScheme_macOS.meta | 0 .../Contents/_CodeSignature.meta | 0 .../Contents/_CodeSignature/CodeResources | 0 .../_CodeSignature/CodeResources.meta | 0 {Scripts => Runtime}/NativeColorScheme.asmdef | 0 .../NativeColorScheme.asmdef.meta | 0 Scripts/.DS_Store | Bin 6148 -> 0 bytes Scripts/ColorScheme.cs | 9 -- Scripts/ColorSchemeUtil.cs | 21 ----- Scripts/Editor/EditorThemeSwitcher.cs | 27 ------ external~/.DS_Store | Bin 6148 -> 0 bytes external~/Dark Detector Xcode/.DS_Store | Bin 6148 -> 0 bytes .../ColorScheme_macOS/.DS_Store | Bin 6148 -> 0 bytes external~/Dark Detector Xcode/iOS/.DS_Store | Bin 6148 -> 0 bytes package.json | 4 +- 35 files changed, 147 insertions(+), 60 deletions(-) delete mode 100644 .DS_Store rename Scripts/Editor.meta => Editor.meta (77%) create mode 100644 Editor/EditorThemeSwitcher.cs rename {Scripts/Editor => Editor}/EditorThemeSwitcher.cs.meta (100%) create mode 100644 Editor/NativeColorScheme.Editor.asmdef create mode 100644 Editor/NativeColorScheme.Editor.asmdef.meta rename Scripts.meta => Runtime.meta (100%) create mode 100644 Runtime/ColorScheme.cs rename {Scripts => Runtime}/ColorScheme.cs.meta (100%) create mode 100644 Runtime/ColorSchemeUtil.cs rename {Scripts => Runtime}/ColorSchemeUtil.cs.meta (100%) rename {Scripts => Runtime}/ColorScheme_iOS.mm (100%) rename {Scripts => Runtime}/ColorScheme_iOS.mm.meta (100%) rename {Scripts => Runtime}/ColorScheme_macOS.bundle.meta (100%) rename {Scripts => Runtime}/ColorScheme_macOS.bundle/Contents.meta (100%) rename {Scripts => Runtime}/ColorScheme_macOS.bundle/Contents/Info.plist (100%) rename {Scripts => Runtime}/ColorScheme_macOS.bundle/Contents/Info.plist.meta (100%) rename {Scripts => Runtime}/ColorScheme_macOS.bundle/Contents/MacOS.meta (100%) rename {Scripts => Runtime}/ColorScheme_macOS.bundle/Contents/MacOS/ColorScheme_macOS (100%) rename {Scripts => Runtime}/ColorScheme_macOS.bundle/Contents/MacOS/ColorScheme_macOS.meta (100%) rename {Scripts => Runtime}/ColorScheme_macOS.bundle/Contents/_CodeSignature.meta (100%) rename {Scripts => Runtime}/ColorScheme_macOS.bundle/Contents/_CodeSignature/CodeResources (100%) rename {Scripts => Runtime}/ColorScheme_macOS.bundle/Contents/_CodeSignature/CodeResources.meta (100%) rename {Scripts => Runtime}/NativeColorScheme.asmdef (100%) rename {Scripts => Runtime}/NativeColorScheme.asmdef.meta (100%) delete mode 100644 Scripts/.DS_Store delete mode 100644 Scripts/ColorScheme.cs delete mode 100644 Scripts/ColorSchemeUtil.cs delete mode 100644 Scripts/Editor/EditorThemeSwitcher.cs delete mode 100644 external~/.DS_Store delete mode 100644 external~/Dark Detector Xcode/.DS_Store delete mode 100644 external~/Dark Detector Xcode/ColorScheme_macOS/.DS_Store delete mode 100644 external~/Dark Detector Xcode/iOS/.DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index d10a9e1732dc0031f74a73f9521c6d27b904f87f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK!AiqG5PjPg+M-DDpdRxDLhl}8hzHNPc&u%u7FtuZf`=+O`XdFwgFoRndG^ij zQnRM*Nkn7@X5MCYW_R+^X0iZGazE?>9RMw=V69EFMr2;JA~o;XB^p^{GU{f7d^)Q{ zs^hORAkVIWV~jAyJa~Tf=S6vLnx|=hlK1IrHQ!!8&L7`T!};OX`Pp^px6$q~6>VJM z0dv}0+~5)uJOve)i@o(x7f{xN_45lA2Ezer$6#>vB$!pONX&La~;34 z@h22xcc(wH;V`j7waS1p5He7AmmTT (byte)EditorPrefs.GetInt(SETTING_NAME, 0) switch { + 1 => ColorScheme.Light, + 2 => ColorScheme.Dark, + _ => null + }; + set { + int newValue = value switch { + ColorScheme.Light => 1, + ColorScheme.Dark => 2, + _ => 0 + }; + EditorPrefs.SetInt(SETTING_NAME, newValue); + } + } + + [InitializeOnLoadMethod] + static void Load() { + switchSkinMethod = System.Reflection.Assembly.GetAssembly(typeof(UnityEditorInternal.AssetStore)).GetType("UnityEditorInternal.InternalEditorUtility", true).GetMethod("SwitchSkinAndRepaintAllViews"); + + EditorApplication.update += UpdateColorScheme; + //EditorApplication.focusChanged += FocusChanged; + SetColorScheme(DesiredAppearance); + } + + private static void FocusChanged(bool state) + => UpdateColorScheme(); + + private static void SetDesiredColorScheme(ColorScheme? colorScheme) { + DesiredAppearance = colorScheme; + SetColorScheme(DesiredAppearance, true); + } + + private static void UpdateColorScheme() + => SetColorScheme(DesiredAppearance); + + private static void SetColorScheme(ColorScheme? colorScheme, bool force = false) { + ColorScheme finalColorScheme = colorScheme ?? ColorSchemeUtil.Current ?? ColorScheme.Light; + + if (finalColorScheme != DesiredAppearance || force) { + Menu.SetChecked(SYSTEM_PATH, colorScheme == null); + Menu.SetChecked(LIGHT_PATH, colorScheme == ColorScheme.Light); + Menu.SetChecked(DARK_PATH, colorScheme == ColorScheme.Dark); + + if (finalColorScheme == ColorScheme.Dark ^ EditorGUIUtility.isProSkin) { + switchSkinMethod.Invoke(null, null); + } + } + } + + // MARK: - Menu + + [MenuItem(SYSTEM_PATH, priority = 0)] + private static void SetSystem() + => SetDesiredColorScheme(null); + + [MenuItem(LIGHT_PATH, priority = 11)] + private static void SetLight() + => SetDesiredColorScheme(ColorScheme.Light); + + [MenuItem(DARK_PATH, priority = 12)] + private static void SetDark() + => SetDesiredColorScheme(ColorScheme.Dark); + + // MARK: - Constants + + private const string SETTING_NAME = "NativeColorScheme.ColorScheme"; + + private const string SYSTEM_PATH = "Window/Color Scheme/System"; + private const string LIGHT_PATH = "Window/Color Scheme/Light"; + private const string DARK_PATH = "Window/Color Scheme/Dark"; + } +} +#endif \ No newline at end of file diff --git a/Scripts/Editor/EditorThemeSwitcher.cs.meta b/Editor/EditorThemeSwitcher.cs.meta similarity index 100% rename from Scripts/Editor/EditorThemeSwitcher.cs.meta rename to Editor/EditorThemeSwitcher.cs.meta diff --git a/Editor/NativeColorScheme.Editor.asmdef b/Editor/NativeColorScheme.Editor.asmdef new file mode 100644 index 0000000..1e5e1fb --- /dev/null +++ b/Editor/NativeColorScheme.Editor.asmdef @@ -0,0 +1,18 @@ +{ + "name": "NativeColorScheme.Editor", + "rootNamespace": "NativeColorScheme.Editor", + "references": [ + "GUID:c8c56aad610fe4ee3936149e38efa88a" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": false, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Editor/NativeColorScheme.Editor.asmdef.meta b/Editor/NativeColorScheme.Editor.asmdef.meta new file mode 100644 index 0000000..86b3dc5 --- /dev/null +++ b/Editor/NativeColorScheme.Editor.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 462bf2ad28b614823bd0d2acdff745ff +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts.meta b/Runtime.meta similarity index 100% rename from Scripts.meta rename to Runtime.meta diff --git a/Runtime/ColorScheme.cs b/Runtime/ColorScheme.cs new file mode 100644 index 0000000..db26fbc --- /dev/null +++ b/Runtime/ColorScheme.cs @@ -0,0 +1,6 @@ +namespace NativeColorScheme { + public enum ColorScheme : byte { + Light = 1, + Dark = 2 + } +} \ No newline at end of file diff --git a/Scripts/ColorScheme.cs.meta b/Runtime/ColorScheme.cs.meta similarity index 100% rename from Scripts/ColorScheme.cs.meta rename to Runtime/ColorScheme.cs.meta diff --git a/Runtime/ColorSchemeUtil.cs b/Runtime/ColorSchemeUtil.cs new file mode 100644 index 0000000..0104ce0 --- /dev/null +++ b/Runtime/ColorSchemeUtil.cs @@ -0,0 +1,29 @@ +#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_IOS +using System.Runtime.InteropServices; +#endif + +namespace NativeColorScheme { + public static class ColorSchemeUtil { +#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX + [DllImport("ColorScheme_macOS")] + private static extern int getCurrentColorScheme_macOS(); + + public static ColorScheme? Current => getCurrentColorScheme_macOS() switch { + 1 => ColorScheme.Light, + 2 => ColorScheme.Dark, + _ => null + }; +#elif UNITY_IOS || UNITY_TVOS + [DllImport("__Internal")] + private static extern int getCurrentColorScheme_iOS(); + + public static ColorScheme? Current => getCurrentColorScheme_iOS() switch { + 1 => ColorScheme.Light, + 2 => ColorScheme.Dark, + _ => null + }; +#else + public static ColorScheme? Current => null; +#endif + } +} \ No newline at end of file diff --git a/Scripts/ColorSchemeUtil.cs.meta b/Runtime/ColorSchemeUtil.cs.meta similarity index 100% rename from Scripts/ColorSchemeUtil.cs.meta rename to Runtime/ColorSchemeUtil.cs.meta diff --git a/Scripts/ColorScheme_iOS.mm b/Runtime/ColorScheme_iOS.mm similarity index 100% rename from Scripts/ColorScheme_iOS.mm rename to Runtime/ColorScheme_iOS.mm diff --git a/Scripts/ColorScheme_iOS.mm.meta b/Runtime/ColorScheme_iOS.mm.meta similarity index 100% rename from Scripts/ColorScheme_iOS.mm.meta rename to Runtime/ColorScheme_iOS.mm.meta diff --git a/Scripts/ColorScheme_macOS.bundle.meta b/Runtime/ColorScheme_macOS.bundle.meta similarity index 100% rename from Scripts/ColorScheme_macOS.bundle.meta rename to Runtime/ColorScheme_macOS.bundle.meta diff --git a/Scripts/ColorScheme_macOS.bundle/Contents.meta b/Runtime/ColorScheme_macOS.bundle/Contents.meta similarity index 100% rename from Scripts/ColorScheme_macOS.bundle/Contents.meta rename to Runtime/ColorScheme_macOS.bundle/Contents.meta diff --git a/Scripts/ColorScheme_macOS.bundle/Contents/Info.plist b/Runtime/ColorScheme_macOS.bundle/Contents/Info.plist similarity index 100% rename from Scripts/ColorScheme_macOS.bundle/Contents/Info.plist rename to Runtime/ColorScheme_macOS.bundle/Contents/Info.plist diff --git a/Scripts/ColorScheme_macOS.bundle/Contents/Info.plist.meta b/Runtime/ColorScheme_macOS.bundle/Contents/Info.plist.meta similarity index 100% rename from Scripts/ColorScheme_macOS.bundle/Contents/Info.plist.meta rename to Runtime/ColorScheme_macOS.bundle/Contents/Info.plist.meta diff --git a/Scripts/ColorScheme_macOS.bundle/Contents/MacOS.meta b/Runtime/ColorScheme_macOS.bundle/Contents/MacOS.meta similarity index 100% rename from Scripts/ColorScheme_macOS.bundle/Contents/MacOS.meta rename to Runtime/ColorScheme_macOS.bundle/Contents/MacOS.meta diff --git a/Scripts/ColorScheme_macOS.bundle/Contents/MacOS/ColorScheme_macOS b/Runtime/ColorScheme_macOS.bundle/Contents/MacOS/ColorScheme_macOS similarity index 100% rename from Scripts/ColorScheme_macOS.bundle/Contents/MacOS/ColorScheme_macOS rename to Runtime/ColorScheme_macOS.bundle/Contents/MacOS/ColorScheme_macOS diff --git a/Scripts/ColorScheme_macOS.bundle/Contents/MacOS/ColorScheme_macOS.meta b/Runtime/ColorScheme_macOS.bundle/Contents/MacOS/ColorScheme_macOS.meta similarity index 100% rename from Scripts/ColorScheme_macOS.bundle/Contents/MacOS/ColorScheme_macOS.meta rename to Runtime/ColorScheme_macOS.bundle/Contents/MacOS/ColorScheme_macOS.meta diff --git a/Scripts/ColorScheme_macOS.bundle/Contents/_CodeSignature.meta b/Runtime/ColorScheme_macOS.bundle/Contents/_CodeSignature.meta similarity index 100% rename from Scripts/ColorScheme_macOS.bundle/Contents/_CodeSignature.meta rename to Runtime/ColorScheme_macOS.bundle/Contents/_CodeSignature.meta diff --git a/Scripts/ColorScheme_macOS.bundle/Contents/_CodeSignature/CodeResources b/Runtime/ColorScheme_macOS.bundle/Contents/_CodeSignature/CodeResources similarity index 100% rename from Scripts/ColorScheme_macOS.bundle/Contents/_CodeSignature/CodeResources rename to Runtime/ColorScheme_macOS.bundle/Contents/_CodeSignature/CodeResources diff --git a/Scripts/ColorScheme_macOS.bundle/Contents/_CodeSignature/CodeResources.meta b/Runtime/ColorScheme_macOS.bundle/Contents/_CodeSignature/CodeResources.meta similarity index 100% rename from Scripts/ColorScheme_macOS.bundle/Contents/_CodeSignature/CodeResources.meta rename to Runtime/ColorScheme_macOS.bundle/Contents/_CodeSignature/CodeResources.meta diff --git a/Scripts/NativeColorScheme.asmdef b/Runtime/NativeColorScheme.asmdef similarity index 100% rename from Scripts/NativeColorScheme.asmdef rename to Runtime/NativeColorScheme.asmdef diff --git a/Scripts/NativeColorScheme.asmdef.meta b/Runtime/NativeColorScheme.asmdef.meta similarity index 100% rename from Scripts/NativeColorScheme.asmdef.meta rename to Runtime/NativeColorScheme.asmdef.meta diff --git a/Scripts/.DS_Store b/Scripts/.DS_Store deleted file mode 100644 index 85944b3beb0bb2bca7aefbfde24d77d9f43ea3ff..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHLOHRW;41H4yDrHl#f#ob%BlQL$q+-dU2LSpJMQTWeh{S?Lj=&MP0UUyZ@jM=t zhR{t_A%twn^O70c89z&zH~?H)PWnI(K!+;W+UM|t$hv4lT5(1eU5N33A;y?tio9WM z6MvBbsogQoQD9D8t=|+^tl|ypdC97tVuTX+n9y!IzwHmlMZO3Lxs&cDG4dkIM)P7s z-%j_be7ku5INL1FWGitNv(=nlxfSeTzX8(z_uCSnJv;eP_)q)Fb0f)B?Iz)@KnJhVx<^f9UMXnKx}h52(P7= z5FZ~giC8Ieh2qqesID%y7*5?e@1tE3u~JlbxY&HS_+%G56c?V(_&%7!C5kp01I9p| zfgQc=$@xE6-~ZR0?9Lc42L2TTuAL3DlqtotwUL~hwVrxS6%o5iap}T~a1_&4|0!`@ Xg!4XP60uTLSNjkUHcX6x-(}zvHDO}9 diff --git a/Scripts/ColorScheme.cs b/Scripts/ColorScheme.cs deleted file mode 100644 index a788fd7..0000000 --- a/Scripts/ColorScheme.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace NativeColorScheme { - public enum ColorScheme : byte { - Unknown = 0, - Light = 1, - Dark = 2 - } -} \ No newline at end of file diff --git a/Scripts/ColorSchemeUtil.cs b/Scripts/ColorSchemeUtil.cs deleted file mode 100644 index a9dd59b..0000000 --- a/Scripts/ColorSchemeUtil.cs +++ /dev/null @@ -1,21 +0,0 @@ -#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_IOS -using System.Runtime.InteropServices; -#endif - -namespace NativeColorScheme { - public static class ColorSchemeUtil { -#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX - [DllImport("ColorScheme_macOS")] - private static extern int getCurrentColorScheme_macOS(); - - public static ColorScheme CurrentColorScheme => (ColorScheme)getCurrentColorScheme_macOS(); -#elif UNITY_IOS || UNITY_TVOS - [DllImport("__Internal")] - private static extern int getCurrentColorScheme_iOS(); - - public static ColorScheme CurrentColorScheme => (ColorScheme)getCurrentColorScheme_iOS(); -#else - public static ColorScheme CurrentColorScheme => ColorScheme.Unknown; -#endif - } -} \ No newline at end of file diff --git a/Scripts/Editor/EditorThemeSwitcher.cs b/Scripts/Editor/EditorThemeSwitcher.cs deleted file mode 100644 index 001c36c..0000000 --- a/Scripts/Editor/EditorThemeSwitcher.cs +++ /dev/null @@ -1,27 +0,0 @@ -#if UNITY_EDITOR_OSX -using UnityEditor; -using UnityEngine; - -namespace NativeColorScheme { - [InitializeOnLoad] - public class EditorThemeSwitcher { - static EditorThemeSwitcher() { - EditorApplication.playModeStateChanged += CheckAndSwitchSkin; - CheckAndSwitchSkin(PlayModeStateChange.EnteredEditMode); - } - - private static void CheckAndSwitchSkin(PlayModeStateChange state) { - if (state == PlayModeStateChange.EnteredEditMode) { - if (ColorSchemeUtil.CurrentColorScheme == ColorScheme.Dark ^ EditorGUIUtility.isProSkin) { - System.Reflection.Assembly.GetAssembly(typeof(UnityEditorInternal.AssetStore)).GetType("UnityEditorInternal.InternalEditorUtility", true).GetMethod("SwitchSkinAndRepaintAllViews").Invoke(null, null); - } - } - } - - [MenuItem("Tools/Debug/Print Current Color Scheme")] - private static void PrintCurrentColorScheme() { - Debug.Log(ColorSchemeUtil.CurrentColorScheme); - } - } -} -#endif \ No newline at end of file diff --git a/external~/.DS_Store b/external~/.DS_Store deleted file mode 100644 index d526921b69bf8856101100aeb3f0e81b1380fa07..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK!AiqG5S^(NqP-Nnc-&v;AFO4?56GoQZBr_kc1x+AJmlz)_$PjlpWvI_L0Y0v zQKW~x5T$B)&BXh=i_T(EbB;R}=d;w|fGiVh8}2l|F#qnb2PzTMyhCDFGl4oF4rjy_UDH)mobEC9j9OvgUQS5&GXyU zPuSHj*z5bfN3omiU>);F_u zD4gDo=ex9=*k`oS6fgz$6*$S4L#hAQ-}nFfB)c*NOo2`*!2M8$F;ddn+DcApt%Kjf p#bjNR@sol{D#chUrT7w_3~?tDpjT`%A_B8N0!aoNOo4w@-~;OmM)?2$ diff --git a/external~/Dark Detector Xcode/.DS_Store b/external~/Dark Detector Xcode/.DS_Store deleted file mode 100644 index b96295aa5952e96d3680fde1c6dd5c20c23f51d0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKu};H44E41cQn8c?#`}f-K}drb8S()@n~EYON>zykF=Svt;v1Ox5I%s9;RAR+ zTQpHXsyb8@*^=*Fe0I+FPPvPT$fftiglJ4eF_dvILi2<0IBQP^YT-c_-m#{f=Cq^* zRXuMr{6z+M?~Z9oHI>lz{w?SVyLf~ByrjImo#gYnTFDZgU$%>?>MWa;^$gx|@icn7 zczi$GHnP|;a8`(q*N4qWJJ0AdJxL``jjQTSF8$HYeE14Xi~(c77&rh1 z^t6hP4j@-c(HJlW_R9dD4<5>xC^mxO=s*)n0AK`j5cIj0;25u%C^mu^fj9{TN~qHk z!$~;oUi}iqMo_}ZY4PE7W~UX33$x?>KDd)h1g$j&jDao#LwOwY{eS*@{of6;Cu6`E z_*V?LD9f`HOVYcww>Z9QJ@gvN!hVh5cL+M+Duyp##i!69uzT(R6U9al7Kr@_1RAU{ I2KLIp7w>XY&j0`b diff --git a/external~/Dark Detector Xcode/ColorScheme_macOS/.DS_Store b/external~/Dark Detector Xcode/ColorScheme_macOS/.DS_Store deleted file mode 100644 index 06daf0857d61bacee4a899a41e35f2df3092f940..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK!AiqG5S^(#M7;DUc-apSp?|Q}h({0k0JTlANWum|@ZceTQa{EI^UcmsTB4UC zqGbkV-exm1$-aS1hKP9fQcsB{L{vZpN5?Qrn^9sCkKHILJ3k=jm=l?%RSrZ$!3yh(Fp zD%R&|ee?Elx&M2$ss6!i-D>-k?|N9b&VV!E4E%2f(6dE~6GgYqfHU9>Y#5O5Lx2iK z!(K6eI$-h$0F>XzELh7dAu+))8up5~17QsXYAD-?!5WVJV1CiCSJZG~8$Q^c%r>EL zeme4p>`ojN-8uu#z%BzvdO4B)fBpUZzZ>LN&VVy;Pz><6tjZaVWW9B8IO(+kdJh#5 nzg}?@f<=m&C@gIRqgBxeyR~h&O9KlP+ diff --git a/external~/Dark Detector Xcode/iOS/.DS_Store b/external~/Dark Detector Xcode/iOS/.DS_Store deleted file mode 100644 index 8b86f5bfb82490c491544899bb1081a0231801e5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKy-veG47N*$AOKlX*1{N6d0?-D5Xrqe|NDK@an0P7%cAf)?ot4k$ zQ`@NgDM&~lTe824?|c`3iQ<@uIJ+)~L<1s9pn|G1v65tYyL(bSKyGI>4Rc-p&t-2F~e z*&(VvU%WeqV`%&Hd}xPm@P>LSk!_7EJzcbOynE@k%VOS>=WH|6ygS@a<>y@dY^OFq z55kX$F<=ZB1E|>|$(o{BW55_N24)P%_rXC0(};~?_;kR87690XI|#&15{w^#hP8H1>1I9p`ffc6_1FpbzK R!UM4%fk1;9W8haAcmq=3bfEwM diff --git a/package.json b/package.json index aaa8566..3e31cac 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { "name": "com.developedwithlove.nativecolorscheme", "displayName": "Native Color Scheme", - "version": "2.0.1", + "version": "2.1.0", "unity": "2020.3", - "description": "System color scheme detection in Unity for macOS and iOS, as well as the Unity Editor on macOS", + "description": "System color scheme detection in Unity for macOS and iOS.", "documentationUrl": "https://github.com/ryanslikesocool/NativeColorScheme", "author": { "name": "Ryan Boyer", From 7a0a5d8a0075f6aa422df3f422d7fbc03d0929ef Mon Sep 17 00:00:00 2001 From: Ryan Boyer Date: Tue, 5 Mar 2024 22:12:32 -0700 Subject: [PATCH 2/2] Update readme --- Editor/EditorThemeSwitcher.cs | 1 - README.md | 45 ++++++++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/Editor/EditorThemeSwitcher.cs b/Editor/EditorThemeSwitcher.cs index ede92e6..0e3ed2b 100644 --- a/Editor/EditorThemeSwitcher.cs +++ b/Editor/EditorThemeSwitcher.cs @@ -1,6 +1,5 @@ #if UNITY_EDITOR_OSX using UnityEditor; -using UnityEngine; namespace NativeColorScheme { public static class EditorThemeSwitcher { diff --git a/README.md b/README.md index f08284b..7d07c5d 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,41 @@ # NativeColorScheme -System color scheme detection in Unity for macOS and iOS (runtime) and macOS (editor). +System color scheme detection in Unity for macOS and iOS. ## Requirements -Color Scheme requires macOS 11 or later, or iOS 14 or later +### Runtime +- macOS 11+ +- iOS 14+ +- tvOS 14+ -**Recommended Installation** (Unity Package Manager) -- "Add package from git URL..." -- `https://github.com/ryanslikesocool/NativeColorScheme.git` +--- -**Alternate Installation** -- Get the latest [release](https://github.com/ryanslikesocool/ColorScheme/releases) -- Open with the desired Unity project -- Import into the Plugins folder +### Editor +- macOS 11+, Unity 2020.3+ + +## Installation (Unity Package Manager) +- Select "Add package from git URL..." from the plus menu in the package manager window. +- Paste the package's git url. +``` +https://github.com/ryanslikesocool/NativeColorScheme.git +``` ## Usage -Get the value from `ColorScheme.ColorSchemeUtil.CurrentColorScheme` from anywhere in your code and use accordingly.\ -Unsupported platforms/OS versions will return `ColorScheme.Unknown`. +### C# +```cs +using NativeColorScheme; + +static class Somewhere { + static Color GetColorForColorScheme() => ColorSchemeUtil.Current switch { + ColorScheme.Light => Color.white, + ColorScheme.Dark => Color.black, + _ => Color.magenta + }; +} +``` +Unsupported platforms or OS versions will return `null`. + +--- + +### Editor +Using the Unity editor on macOS, the plugin will automatically detect the system's color scheme and change the editor accordingly.\ +The preference can be set to `System`, `Light`, or `Dark` from the `Window/Color Scheme` menu. \ No newline at end of file