文档

Unity Engine

Unity Engine

TileAnimationEntityIdData

A struct for the required data for animating a Tile.
阅读时间1 分钟最后更新于 1 个月前

Definition

public struct TileAnimationEntityIdData

Remarks

This is similar to TileAnimationData except it uses EntityIds instead of managed object references.
The example above shows how you can copy a Tile's animation data to be passed to a Tilemap.

Examples

using Unity.Collections;using UnityEngine;using UnityEngine.Tilemaps;public static class TilemapExample{ public struct AnimatedEntityIdData { public TileData m_TileData; public NativeArray<EntityId> m_AnimatedSpriteEntityIds; public float m_Speed; public float m_AnimationStartTime; public TileAnimationFlags m_TileAnimationFlags; public void Dispose() { if (m_AnimatedSpriteEntityIds.IsCreated) m_AnimatedSpriteEntityIds.Dispose(); } } static unsafe void GetTileAnimationEntityIdDataJob(int count, Vector3Int* position, ref AnimatedEntityIdData tileAnimationData, TileAnimationEntityIdData* outTilemapAnimationEntityIdData) { for (var i = 0; i < count; ++i) { ref TileAnimationEntityIdData outTilemapAnimationData = ref *(outTilemapAnimationEntityIdData + i); if (tileAnimationData.m_AnimatedSpriteEntityIds.IsCreated) outTilemapAnimationData.animatedSpritesEntityIds = tileAnimationData.m_AnimatedSpriteEntityIds; outTilemapAnimationData.animationSpeed = tileAnimationData.m_Speed; outTilemapAnimationData.animationStartTime = tileAnimationData.m_AnimationStartTime; outTilemapAnimationData.flags = tileAnimationData.m_TileAnimationFlags; } }}

Properties

Property

Description

animatedSpritesEntityIdsThe array of the Entityids of sprites, ordered by appearance in the animation.
animationSpeedThe animation speed.
animationStartTimeThe start time of the animation. The animation will begin at this time offset.
flagsTileAnimationFlags for controlling the Tile animation.