Skip to content

Commit

Permalink
for some reason the rootlayer event listener did not trigger. this se…
Browse files Browse the repository at this point in the history
…emed to be a much more cleaner solution
  • Loading branch information
bozmir committed Oct 21, 2024
1 parent a3ef2dd commit 8229b6f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
8 changes: 0 additions & 8 deletions Assets/Scripts/Layers/LayerTypes/RootLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ public RootLayer(string name) : base(name)

}

public void Initialize()
{
ReconstructParentsRecursive();
projectDataListener = data => UpdateLayerTreeOrder(0);
ProjectData.Current.OnDataChanged.AddListener(projectDataListener);
}

public void AddLayerToSelection(LayerData layer)
{
if (!SelectedLayers.Contains(layer))
Expand Down Expand Up @@ -53,7 +46,6 @@ public override void DestroyLayer()
{
child.DestroyLayer();
}
ProjectData.Current.OnDataChanged.RemoveListener(projectDataListener);
ProjectData.Current.RemoveLayer(this);
LayerDestroyed.Invoke();
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Projects/ProjectData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public RootLayer RootLayer
private set
{
rootLayer = value;
rootLayer.Initialize();
rootLayer.ReconstructParentsRecursive();
}
}

Expand Down
3 changes: 3 additions & 0 deletions Assets/Scripts/Projects/ProjectDataStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ private void LoadJSON(string json)
ProjectData.Current.isLoading = true;
JsonConvert.PopulateObject(json, ProjectData.Current, serializerSettings);
ProjectData.Current.RootLayer.ReconstructParentsRecursive();


ProjectData.Current.RootLayer.UpdateLayerTreeOrder(0);
Debug.Log("Loaded project with uuid: " + ProjectData.Current.UUID);
ProjectData.Current.OnDataChanged.Invoke(ProjectData.Current);
ProjectData.Current.isLoading = false;
Expand Down

0 comments on commit 8229b6f

Please sign in to comment.