Jump to content
  • 0
pazaway12

How do i remove unused sprites on all files in a folder using ACT Editor?

Question

It can be done manually one by one, 

can someone help me with a script to do it for all the act files inside a folder?

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Heya,

The original script can be opened with Scripts > Open scripts folder > script5_remove_unused_sprites.cs. In your case, you'd want something like this:

foreach (var actPath in Directory.GetFiles(@"C:\Test\", "*.act")) {
	var sprPath = actPath.ReplaceExtension(".spr");
	
	if (!File.Exists(sprPath))
		continue;
	
	var actFile = new Act(actPath, sprPath);
	
	for (int i = actFile.Sprite.Images.Count - 1; i >= 0; i--) {
		if (actFile.FindUsageOf(i).Count == 0) {
			actFile.Sprite.Remove(i, actFile, EditOption.AdjustIndexes);
		}
	}
	
	actFile.SaveWithSprite(actPath, sprPath);
}
  • Love 1
Link to comment
Share on other sites

  • 0
12 hours ago, Tokei said:

Heya,

The original script can be opened with Scripts > Open scripts folder > script5_remove_unused_sprites.cs. In your case, you'd want something like this:

foreach (var actPath in Directory.GetFiles(@"C:\Test\", "*.act")) {
	var sprPath = actPath.ReplaceExtension(".spr");
	
	if (!File.Exists(sprPath))
		continue;
	
	var actFile = new Act(actPath, sprPath);
	
	for (int i = actFile.Sprite.Images.Count - 1; i >= 0; i--) {
		if (actFile.FindUsageOf(i).Count == 0) {
			actFile.Sprite.Remove(i, actFile, EditOption.AdjustIndexes);
		}
	}
	
	actFile.SaveWithSprite(actPath, sprPath);
}

Thanks a lot! This did the job right!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.