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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Question Get position of a point on the sprite shape controller

Discussion in '2D' started by LucasDaSilveira, Nov 20, 2021.

  1. LucasDaSilveira

    LucasDaSilveira

    Joined:
    Mar 29, 2021
    Posts:
    7
    Hi, I want to know if it is possible to get a position of a point in a sprite shape controller Component
    through code.

    For example:
    Let's say I selected this node:
    node.png

    How can I get the X and Y value through code?
    informations.png

    Thank you very much!
     
    Last edited: Nov 21, 2021
  2. DanielTanBK

    DanielTanBK

    Unity Technologies

    Joined:
    Aug 20, 2019
    Posts:
    80
    Last edited: Nov 29, 2021
    LucasDaSilveira likes this.
  3. LucasDaSilveira

    LucasDaSilveira

    Joined:
    Mar 29, 2021
    Posts:
    7
    Hello, thank you for your asnwer!

    I realized that I can get the position through the Spline, but I need the index of the point.

    I think I expressed myself badly, because actually I need to find out what the index is of the selected point, because having the index I can get the position. Do you know if you have a way to find out what the index of the selected point is? Thank you!
     
  4. DanielTanBK

    DanielTanBK

    Unity Technologies

    Joined:
    Aug 20, 2019
    Posts:
    80
    There is no way through the regular Spline/SpriteShape tool, but if you switch the Inspector to Debug mode you would be able to see the list of Control points in the Spline and manually determine which points are which through their position and other details

    More often when creating a SpriteShape through code, a user would create points on multiple indices and then set those positions instead. Is there a certain goal you are trying to achieve doing it your way?
     

    Attached Files:

    Last edited: Dec 2, 2021