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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Sprite.texture field is not working as i want it to

Discussion in 'Scripting' started by noahthegame, Jul 11, 2018.

  1. noahthegame

    noahthegame

    Joined:
    Jun 8, 2017
    Posts:
    35
    all lays in the following bit of the documentation: "
    Sprite.texture
    Texture2D texture;
    Description
    Get the reference to the used texture. If packed this will point to the atlas, if not packed will point to the source sprite."

    the underlinet "If packed this will point to the atlas" is the problem i want to get the texture of the sprite not its atlas. is there anyway on witch i can do this?
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,140
  3. noahthegame

    noahthegame

    Joined:
    Jun 8, 2017
    Posts:
    35
    can i cut it out by code?
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,599
    Yes, but you might want to consider just turning off packing at that point so you can get at the Texture directly, otherwise you'll be writing a lot of VERY fiddly code that may break or violate assumptions of the Unity texture packer.
     
  5. noahthegame

    noahthegame

    Joined:
    Jun 8, 2017
    Posts:
    35
    so how can i turn off packing?
     
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,599
    Google?
     
  7. noahthegame

    noahthegame

    Joined:
    Jun 8, 2017
    Posts:
    35
    yeah sorry
     
  8. noahthegame

    noahthegame

    Joined:
    Jun 8, 2017
    Posts:
    35
  9. noahthegame

    noahthegame

    Joined:
    Jun 8, 2017
    Posts:
    35
    my sprites are in an "atlas" becuse they a cut out by the sprite editor (right?) am not sure i understand