Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question How to create a 2D sprite from an array of Vector3[] vertices

Discussion in '2D' started by Fixel001, Jul 12, 2023.

  1. Fixel001

    Fixel001

    Joined:
    Aug 18, 2020
    Posts:
    1
    So im currently creating a top down shooter that plays around fog of war, the reason i want to create a sprite this way is because i want to use the sprite mask feature, basically i only want enemies to appear when they are in my FOV, and by creating a sprite dynamically during runtime, i can set the sprite mask to act as my vision cone and render enemies only when they are in the vision cone.

    so far i have succeeded in creating a vision cone Screenshot 2023-07-13 052021.png , but i just cant use the existing data to create a sprite with it. Any pointers would be appreciated and thanks in advance :)
     
  2. karderos

    karderos

    Joined:
    Mar 28, 2023
    Posts:
    376
    this method is too cost intensive, you would need to use texture2d.setpixels and texture2d.apply, it would lag your game to hell