Skip to content

Commit

Permalink
Fix error content throwing an exception
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoco007 committed Mar 22, 2024
1 parent 9bbbba1 commit 09c8ef8
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions BeatSaberMarkupLanguage/ViewControllers/BSMLViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ public abstract class BSMLViewController : ViewController, INotifyPropertyChange
protected internal void ClearContents()
{
Destroy(contentObject);

contentObject = new GameObject("Contents");
contentObject.transform.SetParent(transform, false);

RectTransform rectTransform = contentObject.AddComponent<RectTransform>();
rectTransform.anchorMin = Vector2.zero;
rectTransform.anchorMax = Vector2.one;
rectTransform.sizeDelta = Vector2.zero;
rectTransform.anchoredPosition = Vector2.zero;
}

protected override void DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
Expand Down Expand Up @@ -65,15 +74,6 @@ protected void ParseWithFallback()

ClearContents();

contentObject = new GameObject("Contents");
contentObject.transform.SetParent(transform, false);

RectTransform rectTransform = contentObject.AddComponent<RectTransform>();
rectTransform.anchorMin = Vector2.zero;
rectTransform.anchorMax = Vector2.one;
rectTransform.sizeDelta = Vector2.zero;
rectTransform.anchoredPosition = Vector2.zero;

try
{
BSMLParser.instance.Parse(Content, contentObject, this);
Expand Down

0 comments on commit 09c8ef8

Please sign in to comment.