public static Sprite[] GetSpriteFromDraggedPathsOrObjects() { List <Sprite> list = new List <Sprite>(); UnityEngine.Object[] objectReferences = DragAndDrop.objectReferences; for (int i = 0; i < objectReferences.Length; i++) { UnityEngine.Object @object = objectReferences[i]; if (AssetDatabase.Contains(@object)) { if (@object is Sprite) { list.Add(@object as Sprite); } else { if (@object is Texture2D) { list.AddRange(SpriteUtility.TextureToSprites(@object as Texture2D)); } } } } if (list.Count > 0) { return(list.ToArray()); } return(new Sprite[] { SpriteUtility.HandleExternalDrag(Event.current.type == EventType.DragPerform) }); }
public static Sprite[] GetSpriteFromDraggedPathsOrObjects() { List <Sprite> spriteList = new List <Sprite>(); foreach (UnityEngine.Object objectReference in DragAndDrop.objectReferences) { if (AssetDatabase.Contains(objectReference)) { if (objectReference is Sprite) { spriteList.Add(objectReference as Sprite); } else if (objectReference is Texture2D) { spriteList.AddRange((IEnumerable <Sprite>)SpriteUtility.TextureToSprites(objectReference as Texture2D)); } } } if (spriteList.Count > 0) { return(spriteList.ToArray()); } Sprite sprite = SpriteUtility.HandleExternalDrag(Event.current.type == EventType.DragPerform); if (!((UnityEngine.Object)sprite != (UnityEngine.Object)null)) { return((Sprite[])null); } return(new Sprite[1] { sprite }); }
public static List <Sprite> GetSpriteFromPathsOrObjects(UnityEngine.Object[] objects, string[] paths, EventType currentEventType) { List <Sprite> list = new List <Sprite>(); for (int i = 0; i < objects.Length; i++) { UnityEngine.Object @object = objects[i]; if (AssetDatabase.Contains(@object)) { if (@object is Sprite) { list.Add(@object as Sprite); } else if (@object is UnityEngine.Texture2D) { list.AddRange(SpriteUtility.TextureToSprites(@object as UnityEngine.Texture2D)); } } } if (!SpriteUtility.ExistingAssets(objects) && currentEventType == EventType.DragPerform && EditorSettings.defaultBehaviorMode == EditorBehaviorMode.Mode2D) { SpriteUtility.HandleExternalDrag(paths, true, ref list); } return(list); }
public static Sprite TextureToSprite(Texture2D tex) { Sprite[] array = SpriteUtility.TextureToSprites(tex); if (array.Length > 0) { return(array[0]); } return(null); }
public static Sprite TextureToSprite(Texture2D tex) { Sprite[] sprites = SpriteUtility.TextureToSprites(tex); if (sprites.Length > 0) { return(sprites[0]); } return((Sprite)null); }
public static Sprite TextureToSprite(UnityEngine.Texture2D tex) { List <Sprite> list = SpriteUtility.TextureToSprites(tex); Sprite result; if (list.Count > 0) { result = list[0]; } else { result = null; } return(result); }
public static Sprite TextureToSprite(Texture2D tex) { Sprite[] array = SpriteUtility.TextureToSprites(tex); Sprite result; if (array.Length > 0) { result = array[0]; } else { result = null; } return(result); }
public static Sprite[] GetSpritesFromDraggedObjects() { List <Sprite> spriteList = new List <Sprite>(); foreach (UnityEngine.Object objectReference in DragAndDrop.objectReferences) { if (objectReference.GetType() == typeof(Sprite)) { spriteList.Add(objectReference as Sprite); } else if (objectReference.GetType() == typeof(Texture2D)) { spriteList.AddRange((IEnumerable <Sprite>)SpriteUtility.TextureToSprites(objectReference as Texture2D)); } } return(spriteList.ToArray()); }
public static Sprite[] GetSpriteFromPathsOrObjects(UnityEngine.Object[] objects, string[] paths, EventType currentEventType) { List <Sprite> list = new List <Sprite>(); bool flag = false; for (int i = 0; i < objects.Length; i++) { UnityEngine.Object @object = objects[i]; if (AssetDatabase.Contains(@object)) { if (@object is Sprite) { list.Add(@object as Sprite); } else if (@object is Texture2D) { list.AddRange(SpriteUtility.TextureToSprites(@object as Texture2D)); } flag = true; } } Sprite[] result; if (list.Count > 0) { result = list.ToArray(); } else { if (!flag) { Sprite sprite = SpriteUtility.HandleExternalDrag(paths, currentEventType == EventType.DragPerform); if (sprite != null) { result = new Sprite[] { sprite }; return(result); } } result = null; } return(result); }
public static Sprite[] GetSpritesFromDraggedObjects() { List <Sprite> list = new List <Sprite>(); UnityEngine.Object[] objectReferences = DragAndDrop.objectReferences; for (int i = 0; i < objectReferences.Length; i++) { UnityEngine.Object @object = objectReferences[i]; if (@object.GetType() == typeof(Sprite)) { list.Add(@object as Sprite); } else if (@object.GetType() == typeof(Texture2D)) { list.AddRange(SpriteUtility.TextureToSprites(@object as Texture2D)); } } return(list.ToArray()); }