Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
0x7c13 committed Jun 30, 2023
1 parent bdb0476 commit 4fcb2b7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
8 changes: 5 additions & 3 deletions Assets/Resources/Prefabs/Pal3.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -3857,7 +3857,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: 20}
m_SizeDelta: {x: 1200, y: -40}
m_SizeDelta: {x: 800, y: -40}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!225 &4450587676581078315
CanvasGroup:
Expand All @@ -3883,9 +3883,11 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: e9d6f17a4e68481a9705f217be9b4156, type: 3}
m_Name:
m_EditorClassIdentifier:
thresholdRatio: 1.666667
maxThresholdRatio: 1.66667
minThresholdRatio: 1.4
minWidth: 800
maxWidth: 1200
midWidth: 950
maxWidth: 1100
--- !u!223 &7116787231374669820
Canvas:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,21 +165,21 @@ or nameof(GameSettings.IsAmbientOcclusionEnabled))
TogglePostProcessLayerWhenNeeded();
}

#if UNITY_IOS
#if UNITY_IOS || UNITY_STANDALONE_OSX
if (command.SettingName is nameof(GameSettings.ResolutionScale))
{
StartCoroutine(ReloadAmbientOcclusionSettingAsync());
}
#endif
}

#if UNITY_IOS
#if UNITY_IOS || UNITY_STANDALONE_OSX
private IEnumerator Start()
{
yield return ReloadAmbientOcclusionSettingAsync();
}

// On iOS, the SSAO and Resolution changing are causing the RoundedFrostedGlass
// On iOS and MacOS, the SSAO and Resolution changing are causing the RoundedFrostedGlass
// shader to malfunction. This is a workaround to disable and re-enable SSAO to fix the issue.
private IEnumerator ReloadAmbientOcclusionSettingAsync()
{
Expand Down
13 changes: 10 additions & 3 deletions Assets/Scripts/Pal3/UI/RectTransformWidthResizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ namespace Pal3.UI
[RequireComponent(typeof(RectTransform))]
public class RectTransformWidthResizer : MonoBehaviour
{
public float thresholdRatio;
public float maxThresholdRatio;
public float minThresholdRatio;

public float minWidth;
public float midWidth;
public float maxWidth;

private RectTransform _transform;
Expand All @@ -25,8 +28,12 @@ void OnEnable()

void Update()
{
bool useMinWidth = (float)Screen.width / Screen.height < thresholdRatio;
_transform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, useMinWidth ? minWidth : maxWidth);
float currentRatio = (float) Screen.width / Screen.height;

bool useMaxWidth = currentRatio > maxThresholdRatio;
bool useMinWidth = currentRatio < minThresholdRatio;

_transform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, useMaxWidth ? maxWidth : useMinWidth ? minWidth : midWidth);
}

void OnValidate() => OnEnable();
Expand Down

0 comments on commit 4fcb2b7

Please sign in to comment.