Skip to content

Commit bf25037

Browse files
committed
feat(UI): Expose more canvas functions
1 parent 3814932 commit bf25037

File tree

2 files changed

+37
-11
lines changed

2 files changed

+37
-11
lines changed

Assets/JCSUnity/Scripts/UI/JCS_CanvasComp.cs

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/**
2+
* $File: JCS_CanvasComp.cs $
3+
* $Date: $
4+
* $Revision: $
5+
* $Creator: Jen-Chieh Shen $
6+
* $Notice: See LICENSE.txt for modification and distribution information
7+
* Copyright (c) 2024 by Shen, Jen-Chieh $
8+
*/
9+
using System;
110
using UnityEngine;
211

312
namespace JCSUnity
@@ -18,15 +27,40 @@ public class JCS_CanvasComp<T> : MonoBehaviour
1827

1928
public JCS_Canvas canvas { get { return this.mCanvas; } }
2029

30+
public Action<JCS_Canvas> onShow
31+
{
32+
get => mCanvas.onShow;
33+
set => mCanvas.onShow = value;
34+
}
35+
public Action<JCS_Canvas> onHide
36+
{
37+
get => mCanvas.onHide;
38+
set => mCanvas.onHide = value;
39+
}
40+
public Action<JCS_Canvas> onShowFade
41+
{
42+
get => mCanvas.onShowFade;
43+
set => mCanvas.onShowFade = value;
44+
}
45+
public Action<JCS_Canvas> onHideFade
46+
{
47+
get => mCanvas.onHideFade;
48+
set => mCanvas.onHideFade = value;
49+
}
50+
2151
/* Functions */
2252

2353
protected virtual void Awake()
2454
{
2555
this.mCanvas = this.GetComponent<JCS_Canvas>();
2656
}
2757

28-
public virtual void Show() => mCanvas.Show();
29-
public virtual void Hide() => mCanvas.Hide();
30-
public virtual void ToggleVisibility() => mCanvas.ToggleVisibility();
58+
public virtual bool IsShown() => mCanvas.IsShown();
59+
public virtual void Show(bool mute = false) => mCanvas.Show(mute);
60+
public virtual void Show(bool fade, bool mute = false) => mCanvas.Show(fade, mute);
61+
public virtual void Hide(bool mute = false) => mCanvas.Hide(mute);
62+
public virtual void Hide(bool fade, bool mute = false) => mCanvas.Hide(fade, mute);
63+
public virtual void ToggleVisibility(bool mute = false) => mCanvas.ToggleVisibility(mute);
64+
public virtual void ToggleVisibility(bool fade, bool mute = false) => mCanvas.ToggleVisibility(fade, mute);
3165
}
3266
}

docs/ScriptReference/UI/JCS_CanvasComp.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,3 @@ Component that requires the component `JCS_Canvas` without actually inherit the
77
| Name | Description |
88
|:--------|:--------------------------------------|
99
| mCanvas | The canvas this component to control. |
10-
11-
## Functions
12-
13-
| Name | Description |
14-
|:-----------------|:--------------------------------------------------|
15-
| Show | Show the canvas, so it's visible on the screen. |
16-
| Hide | Hide the canvas, so it's invisible on the screen. |
17-
| ToggleVisibility | Toggle the canvas' visibility. |

0 commit comments

Comments
 (0)