File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Assets/JCSUnity/Scripts/UI Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 66 * $Notice: See LICENSE.txt for modification and distribution information
77 * Copyright (c) 2016 by Shen, Jen-Chieh $
88 */
9+ using System ;
910using UnityEngine ;
1011using MyBox ;
1112
@@ -24,6 +25,9 @@ public class JCS_Canvas : MonoBehaviour
2425
2526 private const string RESIZE_UI_PATH = "UI/ResizeUI" ;
2627
28+ public Action < JCS_Canvas > onShow = null ; // Execution when canvas is shown.
29+ public Action < JCS_Canvas > onHide = null ; // Execution when canvas is hidden.
30+
2731 private Canvas mCanvas = null ;
2832
2933 private RectTransform mAppRect = null ; // Application Rect (Window)
@@ -165,6 +169,8 @@ public void Show(bool mute = false)
165169 mCanvas . enabled = true ;
166170 if ( ! mute )
167171 JCS_SoundPlayer . PlayByAttachment ( mDeactiveSound , JCS_SoundMethod . PLAY_SOUND ) ;
172+
173+ onShow ? . Invoke ( this ) ;
168174 }
169175
170176 /// <summary>
@@ -175,6 +181,8 @@ public void Hide(bool mute = false)
175181 mCanvas . enabled = false ;
176182 if ( ! mute )
177183 JCS_SoundPlayer . PlayByAttachment ( mActiveSound , JCS_SoundMethod . PLAY_SOUND ) ;
184+
185+ onHide ? . Invoke ( this ) ;
178186 }
179187
180188 /// <summary>
@@ -199,7 +207,7 @@ private void CheckMainCanvas()
199207
200208 if ( main != null )
201209 {
202- JCS_Debug . LogWarning ( "Having multiple main canvases is often not allowed, " + this . gameObject . name ) ;
210+ JCS_Debug . LogWarning ( "Having multiple main canvases is often not allowed: " + this . gameObject . name ) ;
203211 return ;
204212 }
205213
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ Control of the canvas component.
66
77| Name | Description |
88| :----------------| :-------------------------------------------------|
9+ | onShow | Execution when canvas is shown. |
10+ | onHide | Execution when canvas is hidden. |
911| mDisplayOnAwake | If true, show on awake time; otherwise, hide it. |
1012| mMainCanvas | Resizable screen will be attach to this canvas. |
1113| mActiveSound | Play sound when active the canvas. |
You can’t perform that action at this time.
0 commit comments