Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    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:
    4,017
  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:
    2,826
    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:
    2,826
    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