From ecd9188f5a831c1c2d67feea7d53bd39b72d5b50 Mon Sep 17 00:00:00 2001 From: Neil Sarkar Date: Mon, 10 Aug 2020 17:54:19 -0700 Subject: [PATCH] 1.6.8 - Add ForceRender and make OnScreenAdded a delegate method --- CHANGELOG.md | 9 +++++++++ Runtime/Navigation/Navigator.cs | 6 +++--- Runtime/StateMonoBehaviour.cs | 2 ++ Runtime/Views/View.cs | 3 ++- package.json | 2 +- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db0a0bf..78863c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.1.68] - 2020-08-10 + +### Added +- Navigator.OnScreenAdded + +### Changed +- Screen => VioletScreen +- Fix user-initiated render to always use forceRender + ## [0.1.60] - 2020-07-26 ### Added diff --git a/Runtime/Navigation/Navigator.cs b/Runtime/Navigation/Navigator.cs index dc6150c..ca0e06e 100644 --- a/Runtime/Navigation/Navigator.cs +++ b/Runtime/Navigation/Navigator.cs @@ -184,8 +184,6 @@ void LoadScreens() { OnReady?.Invoke(); } - protected Action OnScreenAdded; - #if UNITY_EDITOR [HideInInspector] public VioletScreen EditingScreen; [SerializeField, HideInInspector] ScreenId originalHomeScreen; @@ -232,10 +230,12 @@ public void AddScreen() { } else { canvas.renderMode = RenderMode.ScreenSpaceOverlay; } - OnScreenAdded?.Invoke(gameObject); + OnScreenAdded(gameObject); EditingScreen = screen; } + protected virtual void OnScreenAdded(GameObject gameObject) {} + float lastUpdate; int childCount; void Update() { diff --git a/Runtime/StateMonoBehaviour.cs b/Runtime/StateMonoBehaviour.cs index aee7c2f..f62b538 100644 --- a/Runtime/StateMonoBehaviour.cs +++ b/Runtime/StateMonoBehaviour.cs @@ -74,7 +74,9 @@ void Render() { Violet.LogWarning($"state is null for {name}"); return; } + View.ForceRender = true; State.TriggerChange(); + View.ForceRender = false; CopyState(); } diff --git a/Runtime/Views/View.cs b/Runtime/Views/View.cs index b208a12..3896e82 100644 --- a/Runtime/Views/View.cs +++ b/Runtime/Views/View.cs @@ -91,8 +91,9 @@ void RenderWrapper(TState state, TState lastState) { } } + internal static bool ForceRender; void State_OnChange() { - RenderWrapper(State, LastState); + RenderWrapper(State, ForceRender ? default(TState) : LastState); } void OnEnable() { diff --git a/package.json b/package.json index ace0e9a..3384b0a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.neilsarkar.violetui", - "version": "0.1.67", + "version": "0.1.68", "displayName": "Violet UI", "description": "State-based rendering with live updates in the Unity Editor", "unity": "2019.4",