Skip to content

Commit

Permalink
prevent rebuild if not in tree
Browse files Browse the repository at this point in the history
  • Loading branch information
sscovil committed Jun 8, 2024
1 parent 42408ad commit e62359e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 72 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Now, let's verify you have correctly installed SplitScreen2D:
To get started, add a `SplitScreen2D` node to your scene tree. Then, add a node that represents your 2D play area,
as well as any nodes that represents your players, as children of the `SplitScreen2D` node in the scene tree.

![Example Scene Tree](./screenshots/screenshot_04.png)
![Example Scene Tree](https://raw.githubusercontent.com/sscovil/godot-split-screen-2d-addon/main/screenshots/screenshot_04.png)

Typically, the play area will be a `TileMap` (or an instance of a scene containing a `TileMap`); and players will be
`CharacterBody2D` instances, but that is not required. They can be of any node type that is derived from `Node2D`.
Expand All @@ -65,7 +65,7 @@ Finally, you'll need to configure the `SplitScreen2D` by assigning it a `Play Ar
Configure the `SplitScreen2D` node by selecting it in the scene tree and assigning the `Play Area`, `Min Players`, and
`Max Players` properties in the inspector.

![Example Configuration](./screenshots/screenshot_05.png)
![Example Configuration](https://raw.githubusercontent.com/sscovil/godot-split-screen-2d-addon/main/screenshots/screenshot_05.png)

Alternatively, you can set these properties in code:

Expand Down Expand Up @@ -108,7 +108,7 @@ The `SplitScreen2D` node will automatically rebuild its viewport tree whenever a
the screen size changes. This should be fine, but if you need to disable it for performance reasons, you can adjust the
Performance Optimization settings.

![Performance Optimization](./screenshots/screenshot_06.png)
![Performance Optimization](https://raw.githubusercontent.com/sscovil/godot-split-screen-2d-addon/main/screenshots/screenshot_06.png)

If you need to manually rebuild the viewport tree, you can call the `rebuild()` method:

Expand Down
67 changes: 0 additions & 67 deletions addons/split_screen_2d/dynamic_split_screen.gdshader

This file was deleted.

2 changes: 1 addition & 1 deletion addons/split_screen_2d/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
name="SplitScreen2D"
description="Easily add a split-screen interface to your 2D game in Godot, with support for up to 8 players."
author="Shaun Scovil"
version="0.2.0"
version="0.2.1"
script="plugin.gd"
2 changes: 1 addition & 1 deletion addons/split_screen_2d/split_screen_2d.gd
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func get_screen_size() -> Vector2:


func rebuild(reason: RebuildReason = RebuildReason.EXTERNAL_REQUEST) -> void:
if _is_rebuilding:
if _is_rebuilding or !is_inside_tree():
return

_is_rebuilding = true
Expand Down

0 comments on commit e62359e

Please sign in to comment.