No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SpriteShapeGeometryCreator.cs 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using Unity.Jobs;
  2. using Unity.Collections;
  3. using Unity.Mathematics;
  4. namespace UnityEngine.U2D
  5. {
  6. /// <summary>
  7. /// Custom Post Processing after geometry is generated.
  8. /// </summary>
  9. public abstract class SpriteShapeGeometryCreator : ScriptableObject
  10. {
  11. /// <summary>
  12. /// Get size of the vertices to be allocated for the Job. This is also used to determine the number of indices needed.
  13. /// Current implementaiton only allows 1 vertex to be mapped to 1 index thus the index array will have the same length as the vertex array.
  14. /// </summary>
  15. /// <param name="spriteShapeController">SpriteShapeController of the GameObject.</param>
  16. /// <returns></returns>
  17. public abstract int GetVertexArrayCount(SpriteShapeController spriteShapeController);
  18. /// <summary>
  19. /// Create SpriteShape Geometry.
  20. /// </summary>
  21. /// <param name="spriteShapeController">SpriteShapeController of the GameObject.</param>
  22. /// <param name="indices">Indices of generated geometry. Initialize to max Array count and contains default data. </param>
  23. /// <param name="positions">Position of vertices in generated geometry. Initialize to max Array count and contains default data. </param>
  24. /// <param name="texCoords">Texture Coordinates of vertices in generated geometry. Initialize to max Array count and contains default data. </param>
  25. /// <param name="tangents">Tangent of vertices in generated geometry. Initialize to max Array count and contains default data. </param>
  26. /// <param name="segments">Submeshes in generated geometry. Initialize to max Array count and contains default data. </param>
  27. /// <param name="colliderData">Points that define the path of Collider. </param>
  28. /// <returns></returns>
  29. public abstract JobHandle MakeCreatorJob(SpriteShapeController spriteShapeController, NativeArray<ushort> indices,
  30. NativeSlice<Vector3> positions, NativeSlice<Vector2> texCoords, NativeSlice<Vector4> tangents,
  31. NativeArray<SpriteShapeSegment> segments, NativeArray<float2> colliderData);
  32. /// <summary>
  33. /// Get Versioning so we can check if geometry needs to be generated.
  34. /// </summary>
  35. /// <returns></returns>
  36. public virtual int GetVersion() => GetInstanceID();
  37. }
  38. };