Skip to content

Commit

Permalink
Setting model on RiveView will respect the instance's showFPS propert…
Browse files Browse the repository at this point in the history
…y rather than the global
  • Loading branch information
duncandoit committed Jul 6, 2022
1 parent c3d60aa commit 4948e74
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Source/Components/RiveView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ open class RiveView: RiveRendererView {

// MARK: Debug
private var fpsCounter: FPSCounterView? = nil
public var showFPS: Bool = RiveView.showFPSCounters { didSet { setFPSCounterState() } }
/// Shows or hides the FPS counter on this RiveView
public var showFPS: Bool = RiveView.showFPSCounters { didSet { setFPSCounterVisibility() } }
/// Shows or hides the FPS counters on all RiveViews
public static var showFPSCounters = false

/// Minimalist constructor, call `.configure` to customize the `RiveView` later.
Expand Down Expand Up @@ -57,7 +59,7 @@ open class RiveView: RiveRendererView {
advance(delta: 0)
}

showFPS = RiveView.showFPSCounters
setFPSCounterVisibility()
}

// MARK: - Controls
Expand Down Expand Up @@ -241,7 +243,7 @@ open class RiveView: RiveRendererView {

// MARK: - Debug

private func setFPSCounterState() {
private func setFPSCounterVisibility() {
// Create a new counter view
if showFPS && fpsCounter == nil {
fpsCounter = FPSCounterView()
Expand Down

0 comments on commit 4948e74

Please sign in to comment.