Version: 2022.3
言語: 日本語

Sprite.GetSecondaryTextureCount

マニュアルに切り替える
public int GetSecondaryTextureCount ();

戻り値

int Returns the number of Secondary Textures that the Sprite is using.

説明

Gets the number of Secondary Textures that the Sprite is using.

using UnityEngine;

// Create a Sprite with Secondary Texture properties and retrieves the total number of // Secondary Texture properties the Sprite has.

public class ExampleClass : MonoBehaviour { void Start() { var texture = new Texture2D(64, 64); var secondaryTexture1 = new Texture2D(64, 64); var secondaryTexture2 = new Texture2D(64, 64); var secondaryTexture3 = new Texture2D(64, 64); var secondarySpriteTexture = new[] { new SecondarySpriteTexture() { name = "_SecondaryTexture1", texture = secondaryTexture1 }, new SecondarySpriteTexture() { name = "_SecondaryTexture2", texture = secondaryTexture2 }, new SecondarySpriteTexture() { name = "_SecondaryTexture3", texture = secondaryTexture3 } };

var sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero, 100, 0, SpriteMeshType.FullRect, Vector4.zero, false, secondarySpriteTexture); int spriteSecondaryTextureCount = sprite.GetSecondaryTextureCount(); // This will print 3 since there are 3 Secondary Texture properties in the Sprite. print(spriteSecondaryTextureCount); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961