mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[unity] Added documentation section to GetRepackedSkin methods mentioning the requirement for Destroy() call on output textures and materials. Added to example scene component code as well. Closes #1681.
This commit is contained in:
parent
b1e4c8f2b7
commit
6a9403511d
@ -73,6 +73,11 @@ namespace Spine.Unity.Examples {
|
||||
collectedSkin.AddAttachments(equipsSkin);
|
||||
|
||||
// 2. Create a repacked skin.
|
||||
// Note: materials and textures returned by GetRepackedSkin() behave like 'new Texture2D()' and need to be destroyed
|
||||
if (runtimeMaterial)
|
||||
Destroy(runtimeMaterial);
|
||||
if (runtimeAtlas)
|
||||
Destroy(runtimeAtlas);
|
||||
var repackedSkin = collectedSkin.GetRepackedSkin("Repacked skin", skeletonAnimation.SkeletonDataAsset.atlasAssets[0].PrimaryMaterial, out runtimeMaterial, out runtimeAtlas);
|
||||
collectedSkin.Clear();
|
||||
|
||||
|
||||
@ -121,6 +121,11 @@ namespace Spine.Unity.Examples {
|
||||
var repackedSkin = new Skin("repacked skin");
|
||||
repackedSkin.AddAttachments(skeleton.Data.DefaultSkin); // Include the "default" skin. (everything outside of skin placeholders)
|
||||
repackedSkin.AddAttachments(customSkin); // Include your new custom skin.
|
||||
// Note: materials and textures returned by GetRepackedSkin() behave like 'new Texture2D()' and need to be destroyed
|
||||
if (runtimeMaterial)
|
||||
Destroy(runtimeMaterial);
|
||||
if (runtimeAtlas)
|
||||
Destroy(runtimeAtlas);
|
||||
repackedSkin = repackedSkin.GetRepackedSkin("repacked skin", sourceMaterial, out runtimeMaterial, out runtimeAtlas); // Pack all the items in the skin.
|
||||
skeleton.SetSkin(repackedSkin); // Assign the repacked skin to your Skeleton.
|
||||
if (bbFollower != null) bbFollower.Initialize(true);
|
||||
|
||||
@ -119,6 +119,11 @@ namespace Spine.Unity.Examples {
|
||||
var repackedSkin = new Skin("repacked skin");
|
||||
repackedSkin.AddAttachments(skeleton.Data.DefaultSkin);
|
||||
repackedSkin.AddAttachments(customSkin);
|
||||
// Note: materials and textures returned by GetRepackedSkin() behave like 'new Texture2D()' and need to be destroyed
|
||||
if (runtimeMaterial)
|
||||
Destroy(runtimeMaterial);
|
||||
if (runtimeAtlas)
|
||||
Destroy(runtimeAtlas);
|
||||
repackedSkin = repackedSkin.GetRepackedSkin("repacked skin", sourceMaterial, out runtimeMaterial, out runtimeAtlas);
|
||||
skeleton.SetSkin(repackedSkin);
|
||||
} else {
|
||||
|
||||
@ -217,7 +217,10 @@ namespace Spine.Unity.AttachmentTools {
|
||||
|
||||
#region Runtime Repacking
|
||||
/// <summary>
|
||||
/// Fills the outputAttachments list with new attachment objects based on the attachments in sourceAttachments, but mapped to a new single texture using the same material.</summary>
|
||||
/// Fills the outputAttachments list with new attachment objects based on the attachments in sourceAttachments,
|
||||
/// but mapped to a new single texture using the same material.</summary>
|
||||
/// <remarks>Returned <c>Material</c> and <c>Texture</c> behave like <c>new Texture2D()</c>, thus you need to call <c>Destroy()</c>
|
||||
/// to free resources.</remarks>
|
||||
/// <param name="sourceAttachments">The list of attachments to be repacked.</param>
|
||||
/// <param name = "outputAttachments">The List(Attachment) to populate with the newly created Attachment objects.</param>
|
||||
///
|
||||
@ -310,7 +313,9 @@ namespace Spine.Unity.AttachmentTools {
|
||||
/// 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>GetRepackedSkin is an expensive operation, preferably call it at level load time.
|
||||
/// No Spine.Atlas object is created so there is no way to find AtlasRegions except through the Attachments using them.</remarks>
|
||||
/// No Spine.Atlas object is created so there is no way to find AtlasRegions except through the Attachments using them.
|
||||
/// Returned <c>Material</c> and <c>Texture</c> behave like <c>new Texture2D()</c>, thus you need to call <c>Destroy()</c>
|
||||
/// to free resources.</remarks>
|
||||
/// <param name="additionalTexturePropertyIDsToCopy">Optional additional textures (such as normal maps) to copy while repacking.
|
||||
/// To copy e.g. the main texture and normal maps, pass 'new int[] { Shader.PropertyToID("_BumpMap") }' at this parameter.</param>
|
||||
/// <param name="additionalOutputTextures">When <c>additionalTexturePropertyIDsToCopy</c> is non-null,
|
||||
@ -342,7 +347,9 @@ namespace Spine.Unity.AttachmentTools {
|
||||
/// 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>GetRepackedSkin is an expensive operation, preferably call it at level load time.
|
||||
/// No Spine.Atlas object is created so there is no way to find AtlasRegions except through the Attachments using them.</remarks>
|
||||
/// No Spine.Atlas object is created so there is no way to find AtlasRegions except through the Attachments using them.
|
||||
/// Returned <c>Material</c> and <c>Texture</c> behave like <c>new Texture2D()</c>, thus you need to call <c>Destroy()</c>
|
||||
/// to free resources.</remarks>
|
||||
public static Skin GetRepackedSkin (this Skin o, string newName, Shader shader, out Material outputMaterial, out Texture2D outputTexture,
|
||||
int maxAtlasSize = 1024, int padding = 2, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps,
|
||||
Material materialPropertySource = null, bool clearCache = false, bool useOriginalNonrenderables = true,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user