From 992fd043fda8dc791c769b5c3bd49defedb9cbbd Mon Sep 17 00:00:00 2001 From: Firerise9402 <90978630+Firerise9402@users.noreply.github.com> Date: Mon, 14 Aug 2023 12:56:10 -0400 Subject: [PATCH 1/4] i think this works on mac now --- Assets/Scripts/AppInfo.cs | 4 +- Assets/Scripts/WindowController.cs | 63 ++++++++++++++++++++++++--- ProjectSettings/ProjectSettings.asset | 6 +-- 3 files changed, 62 insertions(+), 11 deletions(-) diff --git a/Assets/Scripts/AppInfo.cs b/Assets/Scripts/AppInfo.cs index f703a130b..a6630a1e1 100644 --- a/Assets/Scripts/AppInfo.cs +++ b/Assets/Scripts/AppInfo.cs @@ -1,8 +1,8 @@ using System; public static class AppInfo { - public const string Version = "0.0.1039"; - public static readonly DateTime Date = new DateTime(2023, 08, 11, 16, 44, 42, 336, DateTimeKind.Utc); + public const string Version = "0.0.1040"; + public static readonly DateTime Date = new DateTime(2023, 08, 14, 16, 49, 15, 063, DateTimeKind.Utc); } diff --git a/Assets/Scripts/WindowController.cs b/Assets/Scripts/WindowController.cs index f54792f86..428c25870 100644 --- a/Assets/Scripts/WindowController.cs +++ b/Assets/Scripts/WindowController.cs @@ -10,7 +10,14 @@ using Jukebox; using Jukebox.Legacy; using System; +#if UNITY_STANDALONE_WIN using System.Runtime.InteropServices; +#elif UNITY_STANDALONE_OSX +using Foundation; +using Appkit; +#endif + + namespace HeavenStudio { @@ -47,11 +54,17 @@ namespace HeavenStudio here's a google doc with helpful sites(i think) for getting this working on mac https://docs.google.com/document/d/1mvHNNsXC6mo7PV6yZitpKam1fYnud7CXP73YLsebEo8/edit?usp=sharing good luck i cant figure this out + + update: just some default values for nscontroller or whatever it is: + + windowstyle is closable; resizable; tilted + nsbackthingy's default is buffer */ //Credit to Grizmu on the unity forums for this //DLL Stuff for windows #region WinDLLstuff + #if UNITY_STANDALONE_WIN const int SWP_HIDEWINDOW = 0x80; //idk why you would want this but here you go const int SWP_SHOWWINDOW = 0x40; //show window flag. const int SWP_NOMOVE = 0x0002; //don't move the window flag. idk why this either @@ -81,16 +94,50 @@ namespace HeavenStudio uint uFlags ); + System.IntPtr hWnd; + System.IntPtr HWND_TOP = new System.IntPtr(0); + System.IntPtr HWND_TOPMOST = new System.IntPtr(-1); + System.IntPtr HWND_NOTOPMOST = new System.IntPtr(-2); + #elif UNITY_STANDALONE_OSX + + NSWindow _window; + var style = NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.tilted; + + + public void SetWindowPos(double x, double y, double cX, double cY) + { + _window = new NSWindow( + new CoreGraphics.CGRect(x, Screen.mainWindowDisplayInfo.height - y, cx, cy), + style, + NSBackingStore.Buffered, + false + ); + } + + public override NSWindow mainWindowDisplayInfo + { + get { return _window; } + } + + #endif + + public void SetPosition(System.IntPtr ptr, short x, short y, short resX, short resY) { if(!Application.isEditor && !Editor.Editor.instance.fullscreen && (pan != defaultPan | scale != defaultScale)) Reset(); if(Application.isEditor || !Editor.Editor.instance.fullscreen) return; + #if UNITY_STANDALONE_WIN SetWindowPos(ptr, HWND_NOTOPMOST, x, y, resX, resY, SWP_SHOWWINDOW); + #elif UNITY_STANDALONE_OSX + SetWindowPos(x, y, resX, resY); + #endif } - + private void Awake() { + #if UNITY_STANDALONE_WIN hWnd = GetActiveWindow(); + #endif AspectRatioWidth = Screen.mainWindowDisplayInfo.width; AspectRatioHeight = Screen.mainWindowDisplayInfo.height; defaultScale = new Vector3(Screen.width, Screen.height, 0); @@ -98,10 +145,7 @@ namespace HeavenStudio instance = this; } - System.IntPtr hWnd; - System.IntPtr HWND_TOP = new System.IntPtr(0); - System.IntPtr HWND_TOPMOST = new System.IntPtr(-1); - System.IntPtr HWND_NOTOPMOST = new System.IntPtr(-2); + #endregion @@ -145,8 +189,11 @@ namespace HeavenStudio UpdatePan(); //SetShakeIntensity(); - + #if UNITY_STANDALONE_WIN SetPosition(hWnd, Convert.ToInt16(pan.x), Convert.ToInt16(pan.y), Convert.ToInt16(scale.x), Convert.ToInt16(scale.y)); + #elif UNITY_STANDALONE_OSX + SetPosition(pan.x, pan.y, scale.x, scale.y); + #endif //SetPosition(hWnd, Convert.ToInt16(pan.x + shakeResult.x), Convert.ToInt16(pan.y + shakeResult.y), Convert.ToInt16(scale.x), Convert.ToInt16(scale.y)); } @@ -257,7 +304,11 @@ namespace HeavenStudio scale = defaultScale; shakeResult = defaultShake; if(Application.isEditor) return; + #if UNITY_STANDALONE_WIN SetWindowPos(hWnd, HWND_NOTOPMOST, Convert.ToInt16(pan.x), Convert.ToInt16(pan.y), Convert.ToInt16(scale.x), Convert.ToInt16(scale.y), SWP_SHOWWINDOW); + #elif UNITY_STANDALONE_OSX + SetWindowPos(pan.x, pan.y, scale.x, scale.y); + #endif } } } \ No newline at end of file diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 7b6930eac..e1c8e5bfd 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -134,7 +134,7 @@ PlayerSettings: 16:10: 1 16:9: 1 Others: 1 - bundleVersion: 0.0.1039 + bundleVersion: 0.0.1040 preloadedAssets: - {fileID: 102900000, guid: 5348c08b82446e0478cee8bda6c02cfc, type: 3} metroInputSource: 0 @@ -158,11 +158,11 @@ PlayerSettings: applicationIdentifier: Standalone: com.RHeavenStudio.Heaven-Studio buildNumber: - Standalone: 1039 + Standalone: 1040 iPhone: 0 tvOS: 0 overrideDefaultApplicationIdentifier: 0 - AndroidBundleVersionCode: 1039 + AndroidBundleVersionCode: 1040 AndroidMinSdkVersion: 22 AndroidTargetSdkVersion: 0 AndroidPreferredInstallLocation: 1 From 51c099341c323909342cf8d79b69804214bacd6a Mon Sep 17 00:00:00 2001 From: Firerise9402 <90978630+Firerise9402@users.noreply.github.com> Date: Mon, 14 Aug 2023 15:03:44 -0400 Subject: [PATCH 2/4] change to remove broken code so that this will actually work for now --- Assets/Scripts/AppInfo.cs | 4 ++-- Assets/Scripts/WindowController.cs | 20 ++++++++++---------- ProjectSettings/ProjectSettings.asset | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Assets/Scripts/AppInfo.cs b/Assets/Scripts/AppInfo.cs index a6630a1e1..2508fac29 100644 --- a/Assets/Scripts/AppInfo.cs +++ b/Assets/Scripts/AppInfo.cs @@ -1,8 +1,8 @@ using System; public static class AppInfo { - public const string Version = "0.0.1040"; - public static readonly DateTime Date = new DateTime(2023, 08, 14, 16, 49, 15, 063, DateTimeKind.Utc); + public const string Version = "0.0.1041"; + public static readonly DateTime Date = new DateTime(2023, 08, 14, 17, 16, 03, 539, DateTimeKind.Utc); } diff --git a/Assets/Scripts/WindowController.cs b/Assets/Scripts/WindowController.cs index 428c25870..ce4fb467e 100644 --- a/Assets/Scripts/WindowController.cs +++ b/Assets/Scripts/WindowController.cs @@ -10,12 +10,12 @@ using Jukebox; using Jukebox.Legacy; using System; -#if UNITY_STANDALONE_WIN + using System.Runtime.InteropServices; -#elif UNITY_STANDALONE_OSX +/*#if UNITY_STANDALONE_OSX +using AppKit; using Foundation; -using Appkit; -#endif +#endif*/ @@ -98,7 +98,7 @@ namespace HeavenStudio System.IntPtr HWND_TOP = new System.IntPtr(0); System.IntPtr HWND_TOPMOST = new System.IntPtr(-1); System.IntPtr HWND_NOTOPMOST = new System.IntPtr(-2); - #elif UNITY_STANDALONE_OSX + /*#elif UNITY_STANDALONE_OSX NSWindow _window; var style = NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.tilted; @@ -117,7 +117,7 @@ namespace HeavenStudio public override NSWindow mainWindowDisplayInfo { get { return _window; } - } + }*/ #endif @@ -128,8 +128,8 @@ namespace HeavenStudio if(Application.isEditor || !Editor.Editor.instance.fullscreen) return; #if UNITY_STANDALONE_WIN SetWindowPos(ptr, HWND_NOTOPMOST, x, y, resX, resY, SWP_SHOWWINDOW); - #elif UNITY_STANDALONE_OSX - SetWindowPos(x, y, resX, resY); + //#elif UNITY_STANDALONE_OSX + //SetWindowPos(x, y, resX, resY); #endif } @@ -192,7 +192,7 @@ namespace HeavenStudio #if UNITY_STANDALONE_WIN SetPosition(hWnd, Convert.ToInt16(pan.x), Convert.ToInt16(pan.y), Convert.ToInt16(scale.x), Convert.ToInt16(scale.y)); #elif UNITY_STANDALONE_OSX - SetPosition(pan.x, pan.y, scale.x, scale.y); + //SetPosition(pan.x, pan.y, scale.x, scale.y); #endif //SetPosition(hWnd, Convert.ToInt16(pan.x + shakeResult.x), Convert.ToInt16(pan.y + shakeResult.y), Convert.ToInt16(scale.x), Convert.ToInt16(scale.y)); } @@ -307,7 +307,7 @@ namespace HeavenStudio #if UNITY_STANDALONE_WIN SetWindowPos(hWnd, HWND_NOTOPMOST, Convert.ToInt16(pan.x), Convert.ToInt16(pan.y), Convert.ToInt16(scale.x), Convert.ToInt16(scale.y), SWP_SHOWWINDOW); #elif UNITY_STANDALONE_OSX - SetWindowPos(pan.x, pan.y, scale.x, scale.y); + //SetWindowPos(pan.x, pan.y, scale.x, scale.y); #endif } } diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index e1c8e5bfd..ec9d2f787 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -134,7 +134,7 @@ PlayerSettings: 16:10: 1 16:9: 1 Others: 1 - bundleVersion: 0.0.1040 + bundleVersion: 0.0.1041 preloadedAssets: - {fileID: 102900000, guid: 5348c08b82446e0478cee8bda6c02cfc, type: 3} metroInputSource: 0 @@ -158,11 +158,11 @@ PlayerSettings: applicationIdentifier: Standalone: com.RHeavenStudio.Heaven-Studio buildNumber: - Standalone: 1040 + Standalone: 1041 iPhone: 0 tvOS: 0 overrideDefaultApplicationIdentifier: 0 - AndroidBundleVersionCode: 1040 + AndroidBundleVersionCode: 1041 AndroidMinSdkVersion: 22 AndroidTargetSdkVersion: 0 AndroidPreferredInstallLocation: 1 From ae708d7430d37ff0c3c0837dcdc88ae3564b0d19 Mon Sep 17 00:00:00 2001 From: Firerise9402 <90978630+Firerise9402@users.noreply.github.com> Date: Mon, 14 Aug 2023 16:45:17 -0400 Subject: [PATCH 3/4] idk what any of this really does but frick it commit time --- Assets/Scenes/Editor.unity | 4 ++-- Assets/Scripts/AppInfo.cs | 4 ++-- ProjectSettings/ProjectSettings.asset | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Assets/Scenes/Editor.unity b/Assets/Scenes/Editor.unity index 1cba2a066..de9394a6c 100644 --- a/Assets/Scenes/Editor.unity +++ b/Assets/Scenes/Editor.unity @@ -23600,7 +23600,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: -408.9795, y: -17} + m_AnchoredPosition: {x: -408.97943, y: -17} m_SizeDelta: {x: -817.96, y: -46.29} m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &1121370303 @@ -24767,7 +24767,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 1, y: 0.5} - m_AnchoredPosition: {x: 0, y: 105.87461} + m_AnchoredPosition: {x: 0, y: 103.926414} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 1} --- !u!114 &1154875944 diff --git a/Assets/Scripts/AppInfo.cs b/Assets/Scripts/AppInfo.cs index 2508fac29..9b8d250e7 100644 --- a/Assets/Scripts/AppInfo.cs +++ b/Assets/Scripts/AppInfo.cs @@ -1,8 +1,8 @@ using System; public static class AppInfo { - public const string Version = "0.0.1041"; - public static readonly DateTime Date = new DateTime(2023, 08, 14, 17, 16, 03, 539, DateTimeKind.Utc); + public const string Version = "0.0.1042"; + public static readonly DateTime Date = new DateTime(2023, 08, 14, 20, 40, 09, 178, DateTimeKind.Utc); } diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index ec9d2f787..a762db3e9 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -134,7 +134,7 @@ PlayerSettings: 16:10: 1 16:9: 1 Others: 1 - bundleVersion: 0.0.1041 + bundleVersion: 0.0.1042 preloadedAssets: - {fileID: 102900000, guid: 5348c08b82446e0478cee8bda6c02cfc, type: 3} metroInputSource: 0 @@ -158,11 +158,11 @@ PlayerSettings: applicationIdentifier: Standalone: com.RHeavenStudio.Heaven-Studio buildNumber: - Standalone: 1041 + Standalone: 1042 iPhone: 0 tvOS: 0 overrideDefaultApplicationIdentifier: 0 - AndroidBundleVersionCode: 1041 + AndroidBundleVersionCode: 1042 AndroidMinSdkVersion: 22 AndroidTargetSdkVersion: 0 AndroidPreferredInstallLocation: 1 From 859d10e0f1141f36c8e5540476ea65932920fcd4 Mon Sep 17 00:00:00 2001 From: Firerise9402 <90978630+Firerise9402@users.noreply.github.com> Date: Mon, 14 Aug 2023 16:49:47 -0400 Subject: [PATCH 4/4] Cleanup from mac attempts --- Assets/Scripts/WindowController.cs | 31 ------------------------------ 1 file changed, 31 deletions(-) diff --git a/Assets/Scripts/WindowController.cs b/Assets/Scripts/WindowController.cs index ce4fb467e..f3b269d58 100644 --- a/Assets/Scripts/WindowController.cs +++ b/Assets/Scripts/WindowController.cs @@ -12,10 +12,6 @@ using System; using System.Runtime.InteropServices; -/*#if UNITY_STANDALONE_OSX -using AppKit; -using Foundation; -#endif*/ @@ -98,26 +94,6 @@ namespace HeavenStudio System.IntPtr HWND_TOP = new System.IntPtr(0); System.IntPtr HWND_TOPMOST = new System.IntPtr(-1); System.IntPtr HWND_NOTOPMOST = new System.IntPtr(-2); - /*#elif UNITY_STANDALONE_OSX - - NSWindow _window; - var style = NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.tilted; - - - public void SetWindowPos(double x, double y, double cX, double cY) - { - _window = new NSWindow( - new CoreGraphics.CGRect(x, Screen.mainWindowDisplayInfo.height - y, cx, cy), - style, - NSBackingStore.Buffered, - false - ); - } - - public override NSWindow mainWindowDisplayInfo - { - get { return _window; } - }*/ #endif @@ -128,8 +104,6 @@ namespace HeavenStudio if(Application.isEditor || !Editor.Editor.instance.fullscreen) return; #if UNITY_STANDALONE_WIN SetWindowPos(ptr, HWND_NOTOPMOST, x, y, resX, resY, SWP_SHOWWINDOW); - //#elif UNITY_STANDALONE_OSX - //SetWindowPos(x, y, resX, resY); #endif } @@ -191,10 +165,7 @@ namespace HeavenStudio #if UNITY_STANDALONE_WIN SetPosition(hWnd, Convert.ToInt16(pan.x), Convert.ToInt16(pan.y), Convert.ToInt16(scale.x), Convert.ToInt16(scale.y)); - #elif UNITY_STANDALONE_OSX - //SetPosition(pan.x, pan.y, scale.x, scale.y); #endif - //SetPosition(hWnd, Convert.ToInt16(pan.x + shakeResult.x), Convert.ToInt16(pan.y + shakeResult.y), Convert.ToInt16(scale.x), Convert.ToInt16(scale.y)); } private void UpdatePan() @@ -306,8 +277,6 @@ namespace HeavenStudio if(Application.isEditor) return; #if UNITY_STANDALONE_WIN SetWindowPos(hWnd, HWND_NOTOPMOST, Convert.ToInt16(pan.x), Convert.ToInt16(pan.y), Convert.ToInt16(scale.x), Convert.ToInt16(scale.y), SWP_SHOWWINDOW); - #elif UNITY_STANDALONE_OSX - //SetWindowPos(pan.x, pan.y, scale.x, scale.y); #endif } }