Skip to content

Commit bad8e82

Browse files
committed
feat(UI): Add is shown flag to canvas
1 parent 9c829fc commit bad8e82

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Assets/JCSUnity/Scripts/UI/JCS_Canvas.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public static JCS_Canvas GuessCanvas(Transform trans = null)
133133
public void AddComponentToResizeCanvas(Component com)
134134
{
135135
Transform newParent = (mResizeUI != null) ? mResizeUI.transform : this.mCanvas.transform;
136+
136137
if (newParent == null)
137138
JCS_Debug.LogError("Attach resize canvas exception: " + com);
138139
else
@@ -165,13 +166,21 @@ public void Hide(bool mute = false)
165166
JCS_SoundPlayer.PlayByAttachment(mActiveSound, JCS_SoundMethod.PLAY_SOUND);
166167
}
167168

169+
/// <summary>
170+
/// Return true if the canvas is currently visible.
171+
/// </summary>
172+
public bool IsShown()
173+
{
174+
return mCanvas.enabled;
175+
}
176+
168177
/// <summary>
169178
/// Toggle the canvas' visibility.
170179
/// </summary>
171180
/// <param name="mute"> True to mute the sound. </param>
172181
public void ToggleVisibility(bool mute = false)
173182
{
174-
if (mCanvas.enabled)
183+
if (IsShown())
175184
Hide(mute);
176185
else
177186
Show(mute);

0 commit comments

Comments
 (0)