Skip to content

Commit

Permalink
1.6.8 - Add ForceRender and make OnScreenAdded a delegate method
Browse files Browse the repository at this point in the history
  • Loading branch information
neilsarkar committed Aug 11, 2020
1 parent 1cfe050 commit ecd9188
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Runtime/Navigation/Navigator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ void LoadScreens() {
OnReady?.Invoke();
}

protected Action<GameObject> OnScreenAdded;

#if UNITY_EDITOR
[HideInInspector] public VioletScreen EditingScreen;
[SerializeField, HideInInspector] ScreenId originalHomeScreen;
Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 2 additions & 0 deletions Runtime/StateMonoBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ void Render() {
Violet.LogWarning($"state is null for {name}");
return;
}
View.ForceRender = true;
State.TriggerChange();
View.ForceRender = false;
CopyState();
}

Expand Down
3 changes: 2 additions & 1 deletion Runtime/Views/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit ecd9188

Please sign in to comment.