/// <summary>Creates a clone of an AtlasRegion that uses different Material settings, while retaining the original texture.</summary> public AtlasRegion CloneAtlasRegionWithMaterial(AtlasRegion originalRegion, Material materialTemplate) { var newRegion = originalRegion.Clone(); newRegion.page = GetAtlasPageWithMaterial(originalRegion.page, materialTemplate); return(newRegion); }
protected AtlasRegion CloneAtlasRegionWithMaterial(AtlasRegion originalRegion, List <ReplacementMaterial> replacementMaterials) { var newRegion = originalRegion.Clone(); Material material = null; foreach (var replacement in replacementMaterials) { if (replacement.pageName == originalRegion.page.name) { material = replacement.material; break; } } AtlasPage originalPage = originalRegion.page; var newPage = originalPage.Clone(); newPage.rendererObject = material; newRegion.page = newPage; return(newRegion); }