From 65166ecdbda5f5b968a7227d7ba9d056866361de Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Tue, 7 Aug 2018 15:53:00 +0900 Subject: [PATCH] close #113; UIEffectCapturedImage: 'Capture on enable' option --- .../Scripts/Editor/UIEffectCapturedImageEditor.cs | 4 ++++ .../UIEffect/Scripts/UIEffectCapturedImage.cs | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/Assets/Coffee/UIExtensions/UIEffect/Scripts/Editor/UIEffectCapturedImageEditor.cs b/Assets/Coffee/UIExtensions/UIEffect/Scripts/Editor/UIEffectCapturedImageEditor.cs index 6d5b1cc..902a8d8 100644 --- a/Assets/Coffee/UIExtensions/UIEffect/Scripts/Editor/UIEffectCapturedImageEditor.cs +++ b/Assets/Coffee/UIExtensions/UIEffect/Scripts/Editor/UIEffectCapturedImageEditor.cs @@ -44,6 +44,7 @@ namespace Coffee.UIExtensions _spKeepSizeToRootCanvas = serializedObject.FindProperty("m_KeepCanvasSize"); _spTargetTexture = serializedObject.FindProperty("m_TargetTexture"); _spBlurMode = serializedObject.FindProperty("m_BlurMode"); + _spCaptureOnEnable = serializedObject.FindProperty("m_CaptureOnEnable"); _customAdvancedOption = (qualityMode == QualityMode.Custom) || _spTargetTexture.objectReferenceValue; @@ -76,6 +77,8 @@ namespace Coffee.UIExtensions GUILayout.Space(10); EditorGUILayout.LabelField("Advanced Option", EditorStyles.boldLabel); + EditorGUILayout.PropertyField(_spCaptureOnEnable);// CaptureOnEnable. + EditorGUI.BeginChangeCheck(); QualityMode quality = qualityMode; quality = (QualityMode)EditorGUILayout.EnumPopup("Quality Mode", quality); @@ -165,6 +168,7 @@ namespace Coffee.UIExtensions SerializedProperty _spIterations; SerializedProperty _spKeepSizeToRootCanvas; SerializedProperty _spTargetTexture; + SerializedProperty _spCaptureOnEnable; QualityMode qualityMode { diff --git a/Assets/Coffee/UIExtensions/UIEffect/Scripts/UIEffectCapturedImage.cs b/Assets/Coffee/UIExtensions/UIEffect/Scripts/UIEffectCapturedImage.cs index 85d62eb..3129c72 100644 --- a/Assets/Coffee/UIExtensions/UIEffect/Scripts/UIEffectCapturedImage.cs +++ b/Assets/Coffee/UIExtensions/UIEffect/Scripts/UIEffectCapturedImage.cs @@ -50,6 +50,7 @@ namespace Coffee.UIExtensions [SerializeField][Range(1, 8)] int m_BlurIterations = 1; [SerializeField] bool m_KeepCanvasSize = true; [SerializeField] RenderTexture m_TargetTexture; + [SerializeField] bool m_CaptureOnEnable = false; //################################ @@ -131,6 +132,18 @@ namespace Coffee.UIExtensions /// public RenderTexture targetTexture { get { return m_TargetTexture; } set { m_TargetTexture = value; } } + /// + /// This function is called when the object becomes enabled and active. + /// + protected override void OnEnable() + { + base.OnEnable(); + if (m_CaptureOnEnable && Application.isPlaying) + { + Capture(); + } + } + /// /// This function is called when the MonoBehaviour will be destroyed. ///