Skip to content

Commit 8b0f5f0

Browse files
authored
Merge pull request #97 from kirurobo/dev_mac
Added free positioning for macOS
2 parents 223f012 + 415e86e commit 8b0f5f0

File tree

16 files changed

+251
-81
lines changed

16 files changed

+251
-81
lines changed

UniWinC/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ ExportedObj/
3535
*.csproj
3636
*.unityproj
3737
*.sln
38+
*.slnx
3839
*.suo
3940
*.tmp
4041
*.user
Binary file not shown.
Binary file not shown.

UniWinC/Assets/Kirurobo/UniWindowController/Runtime/Scripts/LowLevel/UniWinCore.cs

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,14 @@ protected class LibUniWinC
8181
[return: MarshalAs(UnmanagedType.Bool)]
8282
public static extern bool IsBottommost();
8383

84-
[DllImport("LibUniWinC",CallingConvention=CallingConvention.Winapi)]
84+
[DllImport("LibUniWinC", CallingConvention=CallingConvention.Winapi)]
8585
[return: MarshalAs(UnmanagedType.Bool)]
8686
public static extern bool IsMaximized();
8787

88+
[DllImport("LibUniWinC", CallingConvention=CallingConvention.Winapi)]
89+
[return: MarshalAs(UnmanagedType.Bool)]
90+
public static extern bool IsFreePositioningEnabled();
91+
8892
[DllImport("LibUniWinC",CallingConvention=CallingConvention.Winapi)]
8993
[return: MarshalAs(UnmanagedType.Bool)]
9094
public static extern bool AttachMyWindow();
@@ -122,8 +126,11 @@ protected class LibUniWinC
122126
[DllImport("LibUniWinC",CallingConvention=CallingConvention.Winapi)]
123127
public static extern void SetBottommost([MarshalAs(UnmanagedType.U1)] bool bEnabled);
124128

125-
[DllImport("LibUniWinC",CallingConvention=CallingConvention.Winapi)]
129+
[DllImport("LibUniWinC", CallingConvention = CallingConvention.Winapi)]
126130
public static extern void SetMaximized([MarshalAs(UnmanagedType.U1)] bool bZoomed);
131+
132+
[DllImport("LibUniWinC", CallingConvention = CallingConvention.Winapi)]
133+
public static extern void EnableFreePositioning([MarshalAs(UnmanagedType.U1)] bool bEnabled);
127134

128135
[DllImport("LibUniWinC",CallingConvention=CallingConvention.Winapi)]
129136
public static extern void SetPosition(float x, float y);
@@ -267,6 +274,18 @@ public static EditorWindow GetGameView()
267274
public bool IsClickThrough { get { return (IsActive && _isClickThrough); } }
268275
private bool _isClickThrough = false;
269276

277+
/// <summary>
278+
/// Determines whether the attached window is borderless (no title bar and borders)
279+
/// </summary>
280+
public bool IsBorderless { get { return (IsActive && _isBorderless); } }
281+
private bool _isBorderless = false;
282+
283+
/// <summary>
284+
/// Determines whether the attached window can be freely positioned (macOS only)
285+
/// </summary>
286+
public bool IsFreePositioningEnabled { get { return (IsActive && _isFreePositioningEnabled); } }
287+
private bool _isFreePositioningEnabled = false;
288+
270289
/// <summary>
271290
/// Type of transparent method for Windows
272291
/// </summary>
@@ -789,9 +808,21 @@ public void SetKeyColor(Color32 color)
789808
LibUniWinC.SetKeyColor((UInt32)(color.b * 0x10000 + color.g * 0x100 + color.r));
790809
keyColor = color;
791810
}
792-
#endregion
811+
#endregion
812+
813+
#region for macOS only
814+
/// <summary>
815+
/// ウィンドウの自由配置を設定/解除(macOSのみ対応)
816+
/// </summary>
817+
/// <param name="enabled"></param>
818+
public void EnableFreePositioning(bool enabled)
819+
{
820+
LibUniWinC.EnableFreePositioning(enabled);
821+
_isFreePositioningEnabled = LibUniWinC.IsFreePositioningEnabled();
822+
}
823+
#endregion
793824

794-
#region About monitors
825+
#region About monitors
795826
/// <summary>
796827
/// Get the monitor index where the window is located
797828
/// </summary>

UniWinC/Assets/Kirurobo/UniWindowController/Runtime/Scripts/UniWindowController.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,20 @@ public bool allowDropFiles
276276
/// </summary>
277277
[Tooltip("Will be used the next time the window becomes transparent")]
278278
public Color32 keyColor = new Color32(0x01, 0x00, 0x01, 0x00);
279-
279+
280+
/// <summary>
281+
/// macOSで、メニューバーより上にウィンドウを配置できるようにするか
282+
/// </summary>
283+
public bool isFreePositioningEnabled
284+
{
285+
get { return ((_uniWinCore == null) ? _isFreePositioningEnabled : _isFreePositioningEnabled = _uniWinCore.IsFreePositioningEnabled); }
286+
set { SetFreePositioning(value); }
287+
}
288+
[Header("For macOS only")]
289+
[Tooltip("Disable constrainFrameRect() *Only available on macOS")]
290+
[SerializeField, EditableProperty]
291+
private bool _isFreePositioningEnabled = false;
292+
280293
/// <summary>
281294
/// Is the mouse pointer on an opaque pixel or an object
282295
/// </summary>
@@ -868,6 +881,7 @@ private void UpdateTargetWindow()
868881
SetZoomed(_isZoomed);
869882
SetClickThrough(_isClickThrough);
870883
SetAllowDrop(_allowDropFiles);
884+
SetFreePositioning(_isFreePositioningEnabled);
871885

872886
// ウィンドウ取得時にはモニタ変更と同等の処理を行う
873887
OnMonitorChanged?.Invoke();
@@ -1034,6 +1048,17 @@ private void SetAllowDrop(bool enabled)
10341048
_allowDropFiles = enabled;
10351049
}
10361050

1051+
/// <summary>
1052+
/// macOSで、メニューバーより上を含む自由な位置ウィンドウを配置できるようにする
1053+
/// </summary>
1054+
/// <param name="enabled"></param>
1055+
private void SetFreePositioning(bool enabled)
1056+
{
1057+
if (_uniWinCore == null) return;
1058+
1059+
_uniWinCore.EnableFreePositioning(enabled);
1060+
_isFreePositioningEnabled = _uniWinCore.IsFreePositioningEnabled;
1061+
}
10371062

10381063
/// <summary>
10391064
/// Get the number of connected monitors

UniWinC/Assets/Kirurobo/UniWindowController/Samples/02_UiSample/UiSample.unity

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ RenderSettings:
3838
m_ReflectionIntensity: 1
3939
m_CustomReflection: {fileID: 0}
4040
m_Sun: {fileID: 0}
41-
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
4241
m_UseRadianceAmbientProbe: 0
4342
--- !u!157 &4
4443
LightmapSettings:
@@ -467,6 +466,7 @@ MonoBehaviour:
467466
m_DeselectOnBackgroundClick: 1
468467
m_PointerBehavior: 0
469468
m_CursorLockBehavior: 0
469+
m_ScrollDeltaPerTick: 6
470470
--- !u!114 &305005405 stripped
471471
MonoBehaviour:
472472
m_CorrespondingSourceObject: {fileID: 7299255619972666376, guid: 38b9db02f63429f49bd117e7f988d985,
@@ -1396,6 +1396,11 @@ PrefabInstance:
13961396
propertyPath: _isTransparent
13971397
value: 1
13981398
objectReference: {fileID: 0}
1399+
- target: {fileID: 2416199871598626845, guid: e893aefd93740714b999573b02916984,
1400+
type: 3}
1401+
propertyPath: _isFreePositioningEnabled
1402+
value: 1
1403+
objectReference: {fileID: 0}
13991404
m_RemovedComponents:
14001405
- {fileID: 2416199871598626843, guid: e893aefd93740714b999573b02916984, type: 3}
14011406
m_RemovedGameObjects: []

UniWinC/Assets/Kirurobo/UniWindowController/Samples/02_UiSample/UiSampleController.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,12 @@ private void Update()
233233
{
234234
uniwinc.isZoomed = !uniwinc.isZoomed;
235235
}
236+
237+
// Toggle free positioning
238+
if (InputProxy.GetKeyUp("p"))
239+
{
240+
uniwinc.isFreePositioningEnabled = !uniwinc.isFreePositioningEnabled;
241+
}
236242
}
237243

238244

UniWinC/ProjectSettings/EditorBuildSettings.asset

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ EditorBuildSettings:
55
m_ObjectHideFlags: 0
66
serializedVersion: 2
77
m_Scenes:
8-
- enabled: 1
8+
- enabled: 0
99
path: Assets/Kirurobo/UniWindowController/Samples/00_Menu/SampleMenu.unity
1010
guid: bca881472b6085049ad37ab0ad8fe61e
11-
- enabled: 1
11+
- enabled: 0
1212
path: Assets/Kirurobo/UniWindowController/Samples/01_SimpleSample/SimpleSample.unity
1313
guid: b650a883366376446b7db29169c59420
1414
- enabled: 1
1515
path: Assets/Kirurobo/UniWindowController/Samples/02_UiSample/UiSample.unity
1616
guid: c4f4adeee10bff845b320d93a6b82f54
17-
- enabled: 1
17+
- enabled: 0
1818
path: Assets/Kirurobo/UniWindowController/Samples/03_Fullscreen/FullscreenSample.unity
1919
guid: cc8dc9342a8c4436397f75a2389ffc1a
20-
- enabled: 1
20+
- enabled: 0
2121
path: Assets/Kirurobo/UniWindowController/Samples/04_FileDialog/FileDialogSample.unity
2222
guid: 48a0f5141a4d64ffd86a58d24b841e0c
2323
m_configObjects:

UniWinC/ProjectSettings/ProjectSettings.asset

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ PlayerSettings:
1717
defaultCursor: {fileID: 0}
1818
cursorHotspot: {x: 0, y: 0}
1919
m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}
20-
m_ShowUnitySplashScreen: 1
20+
m_ShowUnitySplashScreen: 0
2121
m_ShowUnitySplashLogo: 1
2222
m_SplashScreenOverlayOpacity: 1
2323
m_SplashScreenAnimation: 1
@@ -77,13 +77,15 @@ PlayerSettings:
7777
androidMinimumWindowHeight: 300
7878
androidFullscreenMode: 1
7979
androidAutoRotationBehavior: 1
80+
androidPredictiveBackSupport: 1
8081
defaultIsNativeResolution: 1
8182
macRetinaSupport: 1
8283
runInBackground: 1
8384
captureSingleScreen: 0
8485
muteOtherAudioSources: 0
8586
Prepare IOS For Recording: 0
8687
Force IOS Speakers When Recording: 0
88+
audioSpatialExperience: 0
8789
deferSystemGesturesMode: 0
8890
hideHomeButton: 0
8991
submitAnalytics: 1
@@ -139,8 +141,9 @@ PlayerSettings:
139141
loadStoreDebugModeEnabled: 0
140142
visionOSBundleVersion: 1.0
141143
tvOSBundleVersion: 1.0
142-
bundleVersion: 0.9.7
143-
preloadedAssets: []
144+
bundleVersion: 0.9.8
145+
preloadedAssets:
146+
- {fileID: 11400000, guid: dc660a2a123d34488abe1d07904475f4, type: 2}
144147
metroInputSource: 0
145148
wsaTransparentSwapchain: 0
146149
m_HolographicPauseOnTrackingLoss: 1
@@ -185,8 +188,10 @@ PlayerSettings:
185188
strictShaderVariantMatching: 0
186189
VertexChannelCompressionMask: 4054
187190
iPhoneSdkVersion: 988
191+
iOSSimulatorArchitecture: 0
188192
iOSTargetOSVersionString: 12.0
189193
tvOSSdkVersion: 0
194+
tvOSSimulatorArchitecture: 0
190195
tvOSRequireExtendedGameController: 0
191196
tvOSTargetOSVersionString: 12.0
192197
VisionOSSdkVersion: 0
@@ -233,6 +238,7 @@ PlayerSettings:
233238
iOSMetalForceHardShadows: 0
234239
metalEditorSupport: 1
235240
metalAPIValidation: 1
241+
metalCompileShaderBinary: 0
236242
iOSRenderExtraFrameOnPause: 0
237243
iosCopyPluginsCodeInsteadOfSymlink: 0
238244
appleDeveloperTeamID:
@@ -530,6 +536,7 @@ PlayerSettings:
530536
switchSocketBufferEfficiency: 4
531537
switchSocketInitializeEnabled: 1
532538
switchNetworkInterfaceManagerInitializeEnabled: 1
539+
switchDisableHTCSPlayerConnection: 0
533540
switchUseNewStyleFilepaths: 0
534541
switchUseLegacyFmodPriorities: 0
535542
switchUseMicroSleepForYield: 1
@@ -696,6 +703,7 @@ PlayerSettings:
696703
metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628,
697704
a: 1}
698705
metroSplashScreenUseBackgroundColor: 0
706+
syncCapabilities: 0
699707
platformCapabilities: {}
700708
metroTargetDeviceFamilies: {}
701709
metroFTAName:

0 commit comments

Comments
 (0)