private void UpdateUV()
        {
            UMAData.GeneratedMaterials umaAtlasList = umaData.generatedMaterials;

            for (int atlasIndex = 0; atlasIndex < umaAtlasList.materials.Count; atlasIndex++)
            {
                var material = umaAtlasList.materials[atlasIndex];
                if (material.umaMaterial.materialType == UMAMaterial.MaterialType.NoAtlas)
                {
                    continue;
                }

                Vector2 finalAtlasAspect = new Vector2(umaGenerator.atlasResolution / material.cropResolution.x, umaGenerator.atlasResolution / material.cropResolution.y);

                for (int atlasElementIndex = 0; atlasElementIndex < material.materialFragments.Count; atlasElementIndex++)
                {
                    Rect tempRect = material.materialFragments[atlasElementIndex].atlasRegion;
                    tempRect.xMin = tempRect.xMin * finalAtlasAspect.x;
                    tempRect.xMax = tempRect.xMax * finalAtlasAspect.x;
                    tempRect.yMin = tempRect.yMin * finalAtlasAspect.y;
                    tempRect.yMax = tempRect.yMax * finalAtlasAspect.y;
                    material.materialFragments[atlasElementIndex].atlasRegion = tempRect;
                }
            }
        }
Пример #2
0
        private void UpdateUV()
        {
            UMAData.GeneratedMaterials umaAtlasList = umaData.generatedMaterials;

            for (int atlasIndex = 0; atlasIndex < umaAtlasList.materials.Count; atlasIndex++)
            {
                Vector2 finalAtlasAspect = new Vector2(umaGenerator.atlasResolution / umaAtlasList.materials[atlasIndex].cropResolution.x, umaGenerator.atlasResolution / umaAtlasList.materials[atlasIndex].cropResolution.y);

                for (int atlasElementIndex = 0; atlasElementIndex < umaAtlasList.materials[atlasIndex].materialFragments.Count; atlasElementIndex++)
                {
                    Rect tempRect = umaAtlasList.materials[atlasIndex].materialFragments[atlasElementIndex].atlasRegion;
                    tempRect.xMin = tempRect.xMin * finalAtlasAspect.x;
                    tempRect.xMax = tempRect.xMax * finalAtlasAspect.x;
                    tempRect.yMin = tempRect.yMin * finalAtlasAspect.y;
                    tempRect.yMax = tempRect.yMax * finalAtlasAspect.y;
                    umaAtlasList.materials[atlasIndex].materialFragments[atlasElementIndex].atlasRegion = tempRect;
                }
            }
        }