@@ -39,7 +39,7 @@ public class ThumbGenerator : MonoBehaviour
3939 public int NumProcessed { get ; private set ; }
4040
4141
42- private List < AssetMaterialCombination > _assets ;
42+ private List < AssetMaterialCombination > _combinations ;
4343 private GameObject _currentGo ;
4444 private ThumbGeneratorComponent _currentTbc ;
4545 private AssetMaterialCombination _currentAmc ;
@@ -50,7 +50,7 @@ public void StartProcessing(bool newOnly = false, bool selectedOnly = false)
5050 {
5151 _camera = Camera . main ;
5252
53- var bgParent = SceneManager . GetActiveScene ( ) . GetRootGameObjects ( ) . FirstOrDefault ( go => go . name == "_BackgroundObjects" ) ;
53+ var bgParent = DefaultEnvironment . transform . parent . gameObject ;
5454 _environmentObjects . Clear ( ) ;
5555 if ( bgParent != null ) {
5656 foreach ( var mr in bgParent . GetComponentsInChildren < MeshRenderer > ( true ) ) {
@@ -73,21 +73,21 @@ public void StartProcessing(bool newOnly = false, bool selectedOnly = false)
7373 return ;
7474 }
7575
76- _assets = new List < AssetMaterialCombination > ( assets
77- . SelectMany ( a => AssetMaterialCombination . GetCombinations ( a . Asset ) )
76+ _combinations = new List < AssetMaterialCombination > ( assets
77+ . SelectMany ( a => AssetMaterialCombination . GetCombinations ( a . Asset , true ) )
7878 ) ;
7979
8080 if ( newOnly ) {
81- _assets = _assets . Where ( a => ! a . HasThumbnail ) . ToList ( ) ;
81+ _combinations = _combinations . Where ( a => ! a . HasThumbnail ) . ToList ( ) ;
8282 }
8383 if ( selectedOnly ) {
8484 var selectedAssets = new HashSet < Asset > ( EditorWindow . GetWindow < AssetBrowser > ( ) . SelectedAssets ) ;
85- _assets = _assets . Where ( a => selectedAssets . Contains ( a . Asset ) ) . ToList ( ) ;
85+ _combinations = _combinations . Where ( a => selectedAssets . Contains ( a . Asset ) ) . ToList ( ) ;
8686 }
8787
8888 NumProcessed = 0 ;
89- TotalProcessing = _assets . Count ;
90- if ( _assets . Count > 0 ) {
89+ TotalProcessing = _combinations . Count ;
90+ if ( _combinations . Count > 0 ) {
9191 IsProcessing = true ;
9292 Process ( NextAsset ( ) ) ;
9393 } else {
@@ -101,7 +101,7 @@ public void StartProcessing(bool newOnly = false, bool selectedOnly = false)
101101
102102 public void StopProcessing ( )
103103 {
104- _assets ? . Clear ( ) ;
104+ _combinations ? . Clear ( ) ;
105105 IsProcessing = false ;
106106 }
107107
@@ -167,11 +167,15 @@ private void DoneProcessing(object sender, EventArgs e)
167167
168168 private AssetMaterialCombination NextAsset ( )
169169 {
170- if ( _assets . Count == 0 ) {
170+ if ( _combinations . Count == 0 ) {
171171 return null ;
172172 }
173- var next = _assets . First ( ) ;
174- _assets . RemoveAt ( 0 ) ;
173+ var next = _combinations . First ( ) ;
174+ if ( next . HasDuplicateVariations ) {
175+ _combinations . RemoveAt ( 0 ) ;
176+ return NextAsset ( ) ;
177+ }
178+ _combinations . RemoveAt ( 0 ) ;
175179 NumProcessed ++ ;
176180 return next ;
177181 }
0 commit comments