Exemple #1
0
        public static void Open(DecalPlacementTool.DecalTemplate template, Action <DecalPlacementTool.DecalTemplate[]> splittedCallback)
        {
            AtlasSplitter window = GetWindow <AtlasSplitter>();

            window.template = template;
            window.Show();

            window.splittedCallback = splittedCallback;
            window.titleContent     = new GUIContent("Split");
        }
Exemple #2
0
        private void Split()
        {
            List <DecalPlacementTool.DecalTemplate> templates = new List <DecalPlacementTool.DecalTemplate>();

            foreach (var rect in visualRects)
            {
                Vector2 tiling = Vector2.zero;
                Vector2 offset = Vector2.zero;
                tiling.x = rect.Rect.width / backRect.width;
                tiling.y = rect.Rect.height / backRect.height;
                offset.x = rect.Rect.x / backRect.width;
                offset.y = rect.Rect.y / backRect.height;

                var templateInstance = new DecalPlacementTool.DecalTemplate(template.DecalMaterial, 100);
                templateInstance.InstancedUV = new Vector4(tiling.x, tiling.y, offset.x, offset.y);
                templateInstance.RecreatePreview();

                templates.Add(templateInstance);
            }

            splittedCallback(templates.ToArray());
            Close();
        }