Skip to content

Commit

Permalink
Merge pull request #171 from sttz/main
Browse files Browse the repository at this point in the history
Fixed exception when viewing a Yarn Project in the inspector that contains no declarations
  • Loading branch information
McJones authored Apr 26, 2022
2 parents ac2f188 + ce5a80d commit 46e3961
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- `ActionManager` no longer logs every single command that it registers. (#165)
- Line view should no longer have unusual interactions around enabling and disabling different effects (#161 and #153).
- Improved the type inference system around the use of functions.
- Fixed exception when viewing a Yarn Project in the inspector that contains no declarations, in Unity 2021.2 and earlier (#168)

This has two pieces, the first is in YarnSpinner Core and adds in support for partial backwards type inference.
This means in many situations where either the l-value or r-value of an expression is known that can be used to provide a type to the other side of the equation.
Expand Down
9 changes: 9 additions & 0 deletions Editor/Importers/YarnProjectImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,15 @@ private bool ShouldShowElement(int index)

private float GetElementHeight(int index, bool useSearch)
{
#if !UNITY_2022_1_OR_NEWER
// Before Unity 2022.1, this callback gets called with
// index 0 even if the list is empty
if (serializedProperty.arraySize == 0)
{
return 0;
}
#endif

if (useSearch == false || ShouldShowElement(index))
{
var item = serializedProperty.GetArrayElementAtIndex(index);
Expand Down

0 comments on commit 46e3961

Please sign in to comment.