Search Unity

How to get selected sprites from Texture asset?

Discussion in 'Immediate Mode GUI (IMGUI)' started by eses, Mar 1, 2018.

  1. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    Hi,

    so my question is how to get selected sprites from Texture asset? I know I can get selection using something like:

    Code (csharp):
    1.  
    2. Selection.GetFiltered (typeof(Object), SelectionMode.Assets);
    3.  
    I also found out that I can iterate all the sprites in texture:

    Code (csharp):
    1.  
    2. Object[] allSprites = AssetDatabase.LoadAllAssetRepresentationsAtPath(path);
    3.  
    But how can I get the editor selection? Selection just shows I've selected a texture sheet.

    Any help would be appreciated!
     
  2. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    I actually figured this out (eventually).

    If someone else needs this - here it is:

    Code (csharp):
    1.  
    2. Sprite[] selSprites = Selection.GetFiltered<Sprite>(SelectionMode.Unfiltered);
    3.  
     
  3. tranminhvu22

    tranminhvu22

    Joined:
    Sep 28, 2022
    Posts:
    1
    thanks