Skip to content

Commit

Permalink
fix(images): when doing a new generation, do not reload all images
Browse files Browse the repository at this point in the history
  • Loading branch information
Morgan-6Freedom committed Feb 14, 2024
1 parent 0515634 commit 9710846
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
20 changes: 18 additions & 2 deletions package/Editor/Images/Images.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ public class Images : EditorWindow
/// </summary>
private static string lastPageToken = string.Empty;

private static bool isVisible = false;

[MenuItem("Window/Scenario/Images")]
public static void ShowWindow()
{
if (isVisible)
return;

lastPageToken = string.Empty;
imageDataList.Clear();
GetInferencesData();

var images = (Images)GetWindow(typeof(Images));
ImagesUI.Init(images);
}
Expand All @@ -37,8 +42,19 @@ private void OnGUI()
private void OnDestroy()
{
ImagesUI.CloseSelectedTextureSection();
DataCache.instance.ClearAllImageData();
}


private void OnBecameVisible()
{
isVisible = true;
}

private void OnBecameInvisible()
{
isVisible = false;
}

public static void GetInferencesData(Action callback_OnDataGet = null) //why get inferences instead of getting the assets ??
{
string request = $"inferences";
Expand Down
1 change: 0 additions & 1 deletion package/Editor/Images/ImagesUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ public void OnGUI(Rect _dimension)
Images.GetInferencesData( () =>
{
isLoading = false;
images.Repaint();
});
}
}
Expand Down
1 change: 0 additions & 1 deletion package/Editor/_Services/DataCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public void FillReservedSpaceForImageData(string inferenceId, string id, string
CommonUtils.FetchTextureFromURL(itm.Url, texture =>
{
itm.texture = texture;
RemoveImageDataAtIndex(GetImageDataIndexByUrl(itm.Url));
});
}

Expand Down
3 changes: 1 addition & 2 deletions package/Editor/_Services/PromptFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ public static void PostInferenceRequest(string inputData, int imagesliderIntValu
guidancesliderValue,
"Default",
seedinputText);

Images.ShowWindow();

GetInferenceStatus(inferenceId, modelId);
Images.ShowWindow();
});
}

Expand Down

0 comments on commit 9710846

Please sign in to comment.