本文整理汇总了C#中UnityEngine.Material.ToSpineAtlasPage方法的典型用法代码示例。如果您正苦于以下问题:C# Material.ToSpineAtlasPage方法的具体用法?C# Material.ToSpineAtlasPage怎么用?C# Material.ToSpineAtlasPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Material
的用法示例。
在下文中一共展示了Material.ToSpineAtlasPage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPageFor
static AtlasPage GetPageFor (Texture texture, Shader shader) {
if (atlasPageCache == null) atlasPageCache = new Dictionary<Texture, AtlasPage>();
AtlasPage atlasPage;
atlasPageCache.TryGetValue(texture, out atlasPage);
if (atlasPage == null) {
var newMaterial = new Material(shader);
atlasPage = newMaterial.ToSpineAtlasPage();
atlasPageCache[texture] = atlasPage;
}
return atlasPage;
}
示例2: GetRepackedSkin
/// <summary>
/// Creates and populates a duplicate skin with cloned attachments that are backed by a new packed texture atlas comprised of all the regions from the original skin.</summary>
/// <remarks>No Spine.Atlas object is created so there is no way to find AtlasRegions except through the Attachments using them.</remarks>
public static Skin GetRepackedSkin (this Skin o, string newName, Shader shader, out Material m, out Texture2D t, int maxAtlasSize = 1024, int padding = 2) {
var skinAttachments = o.Attachments;
var newSkin = new Skin(newName);
var repackedAttachments = new List<Attachment>();
var texturesToPack = new List<Texture2D>();
foreach (var kvp in skinAttachments) {
var newAttachment = kvp.Value.GetClone(true);
if (IsRenderable(newAttachment)) {
texturesToPack.Add(newAttachment.GetAtlasRegion().ToTexture());
repackedAttachments.Add(newAttachment);
}
var key = kvp.Key;
newSkin.AddAttachment(key.slotIndex, key.name, newAttachment);
}
var newTexture = new Texture2D(maxAtlasSize, maxAtlasSize);
newTexture.name = newName;
var rects = newTexture.PackTextures(texturesToPack.ToArray(), padding, maxAtlasSize);
var newMaterial = new Material(shader);
newMaterial.name = newName;
newMaterial.mainTexture = newTexture;
var page = newMaterial.ToSpineAtlasPage();
page.name = newName;
for (int i = 0, n = repackedAttachments.Count; i < n; i++) {
var a = repackedAttachments[i];
var r = rects[i];
var oldRegion = a.GetAtlasRegion();
var newRegion = UVRectToAtlasRegion(r, oldRegion.name, page, oldRegion.offsetX, oldRegion.offsetY, oldRegion.rotate);
a.SetRegion(newRegion);
}
t = newTexture;
m = newMaterial;
return newSkin;
}
示例3: ToAtlasRegionPMAClone
/// <summary>
/// Creates a Spine.AtlasRegion that uses a premultiplied alpha duplicate of the Sprite's texture data.</summary>
public static AtlasRegion ToAtlasRegionPMAClone (this Sprite s, Shader shader) {
var material = new Material(shader);
var tex = s.ToTexture(false);
tex.ApplyPMA(true);
tex.name = s.name + "-pma-";
material.name = tex.name + shader.name;
material.mainTexture = tex;
var page = material.ToSpineAtlasPage();
var region = s.ToAtlasRegion(true);
region.page = page;
return region;
}
示例4: ToAtlasRegion
/// <summary>
/// Creates a Spine.AtlasRegion from a UnityEngine.Sprite. This creates a new AtlasPage object for every AtlasRegion you create. You can centralize Material control by creating a shared atlas page using Material.ToSpineAtlasPage and using the sprite.ToAtlasRegion(AtlasPage) overload.</summary>
public static AtlasRegion ToAtlasRegion (this Sprite s, Material material) {
var region = s.ToAtlasRegion();
region.page = material.ToSpineAtlasPage();
return region;
}
示例5: ToRegionAttachment
/// <summary>
/// Creates a RegionAttachment based on a sprite. This method creates a real, usable AtlasRegion. That AtlasRegion uses a new AtlasPage with the Material provided./// </summary>
public static RegionAttachment ToRegionAttachment (this Sprite sprite, Material material) {
return sprite.ToRegionAttachment(material.ToSpineAtlasPage());
}