Skip to content

Commit

Permalink
com.unity.2d.animation@10.1.4
Browse files Browse the repository at this point in the history
## [10.1.4] - 2024-10-07
### Fixed
- Animation Preview window sometimes does not display deformed Sprites. (DANB-705)
- Sprite Resolver missing sprite previews when dealing with large number of entries. (DANB-714)
- Misaligned label previews in Sprite Resolver's inspector. (DANB-722)
- Sprite Resolver component not updated after Sprite Library Asset has been modified. (DANB-727)
- Sprite Skin breaks in the animation preview window after sprite swap. (DANB-743)
- IK gizmos are displayed in the SceneView when IKManager2D is active in Animation Preview window. (DANB-738)
- IK solvers are misaligned when bones have different depths. (DANB-753)
- Rendering issues with SRP Batching and Sprite mask. (DANB-760)
- Unable to drag sprites into empty rows of the Sprite Library Editor. (DANB-749)
- Sprite Skin deformation systems have outdated data after sprite swap. (DANB-766)
- Setting incorrect computer buffer size. (DANB-768)
- Reenable editor tests.
- Bone buffer binding issues.
- Sprite changed callback listeners.
  • Loading branch information
Unity Technologies committed Oct 7, 2024
1 parent 9bc71b0 commit 711bf4a
Show file tree
Hide file tree
Showing 17 changed files with 350 additions and 145 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

## [10.1.4] - 2024-10-07
### Fixed
- Animation Preview window sometimes does not display deformed Sprites. (DANB-705)
- Sprite Resolver missing sprite previews when dealing with large number of entries. (DANB-714)
- Misaligned label previews in Sprite Resolver's inspector. (DANB-722)
- Sprite Resolver component not updated after Sprite Library Asset has been modified. (DANB-727)
- Sprite Skin breaks in the animation preview window after sprite swap. (DANB-743)
- IK gizmos are displayed in the SceneView when IKManager2D is active in Animation Preview window. (DANB-738)
- IK solvers are misaligned when bones have different depths. (DANB-753)
- Rendering issues with SRP Batching and Sprite mask. (DANB-760)
- Unable to drag sprites into empty rows of the Sprite Library Editor. (DANB-749)
- Sprite Skin deformation systems have outdated data after sprite swap. (DANB-766)
- Setting incorrect computer buffer size. (DANB-768)
- Reenable editor tests.
- Bone buffer binding issues.
- Sprite changed callback listeners.

## [10.1.3] - 2024-07-26
### Fixed
- Sprite Swap overlay Label selection not reacting to mouse clicks. (case DANB-627)
Expand All @@ -14,6 +31,7 @@
- Fixed SpriteSkin's playmode test failures. (case DANB-678)
- Modifying the Sprite Skin component through public API.
- Skinning Editor bone and mesh Visibility sliders too short. (case DANB-681)
- Fixed an issue where opening a Sprite Library Asset, when it is a sub asset, in the Sprite Library Editor, would throw an exception.

## [10.1.2] - 2024-05-06
### Fixed
Expand Down
116 changes: 85 additions & 31 deletions Editor/SpriteLib/SpriteLibraryEditor/DragAndDropManipulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,46 @@ void OnDragEnter(DragEnterEvent evt)
TryStartDrag();
}

void OnDragUpdate(DragUpdatedEvent evt)
{
if (evt.currentTarget == evt.target)
TryStartDrag();

m_IsChildDragged = evt.currentTarget != evt.target;

if (isActiveDrag)
DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

UpdateVisuals();
if (isActiveDrag)
evt.StopImmediatePropagation();
}

void OnDragExit(DragExitedEvent evt)
{
StopDragging();
}

void OnDragLeave(DragLeaveEvent evt)
{
StopDragging();
}

void OnDragPerform(DragPerformEvent evt)
{
if (!isActiveDrag)
return;

DragAndDrop.AcceptDrag();
var spritesData = RetrieveDraggedSprites(DragAndDrop.objectReferences);
if (spritesData.Count > 0)
onDragPerform?.Invoke(spritesData, evt.altKey);

DragAndDrop.objectReferences = new Object[] { };

StopDragging();
}

void TryStartDrag()
{
if (m_IsDragging)
Expand All @@ -70,8 +110,7 @@ void TryStartDrag()
if (DragAndDrop.GetGenericData("user_data") != null)
return;

var spritesData = RetrieveDraggedSprites(DragAndDrop.objectReferences);
if (spritesData.Count == 0)
if (!HasAnyDraggedSprites(DragAndDrop.objectReferences))
return;

if (!m_CanStartDrag())
Expand All @@ -92,45 +131,60 @@ void StopDragging()
UpdateVisuals();
}

void OnDragUpdate(DragUpdatedEvent evt)
void UpdateVisuals()
{
m_IsChildDragged = evt.currentTarget != evt.target;

if (isActiveDrag)
DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

UpdateVisuals();
if (isActiveDrag)
evt.StopImmediatePropagation();
m_OverlayVisual.EnableInClassList(k_DragOverAddClassName, isActiveDrag);
}

void OnDragExit(DragExitedEvent evt)
static bool HasAnyDraggedSprites(Object[] objectReferences)
{
StopDragging();
}
if (objectReferences == null || objectReferences.Length == 0)
return false;

void OnDragLeave(DragLeaveEvent evt)
{
StopDragging();
}
foreach (var objectReference in objectReferences)
{
switch (objectReference)
{
case Sprite:
return true;
case Texture2D texture2D:
{
var texturePath = AssetDatabase.GetAssetPath(texture2D);
foreach (var obj in AssetDatabase.LoadAllAssetsAtPath(texturePath))
{
if (obj is Sprite)
return true;
}

void UpdateVisuals()
{
m_OverlayVisual.EnableInClassList(k_DragOverAddClassName, isActiveDrag);
}
break;
}
case GameObject gameObject:
{
var isPsdGameObjectRoot = gameObject.transform.parent != null;
if (isPsdGameObjectRoot)
continue;

void OnDragPerform(DragPerformEvent evt)
{
if (!isActiveDrag)
return;
var psdFilePath = AssetDatabase.GetAssetPath(gameObject);
if (string.IsNullOrEmpty(psdFilePath))
continue;

StopDragging();
var ext = Path.GetExtension(psdFilePath);
if (k_SupportedPsdExtensions.Contains(ext))
{
foreach (var obj in AssetDatabase.LoadAllAssetsAtPath(psdFilePath))
{
var spriteObj = obj as Sprite;
if (spriteObj != null)
return true;
}
}

var spritesData = RetrieveDraggedSprites(DragAndDrop.objectReferences);
if (spritesData.Count == 0)
return;
break;
}
}
}

onDragPerform?.Invoke(spritesData, evt.altKey);
return true;
}

static List<DragAndDropData> RetrieveDraggedSprites(Object[] objectReferences)
Expand Down
2 changes: 2 additions & 0 deletions Editor/SpriteLib/SpriteLibraryEditor/UI/CategoriesTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public void BindElements(ControllerEvents controllerEvents, ViewEvents viewEvent
m_CategoryListsScrollContainer = this.Q<ScrollView>("CategoryListsScrollView");
m_CategoryListsScrollContainer.pickingMode = PickingMode.Ignore;
m_CategoryListsScrollContainer.Q<VisualElement>("unity-content-and-vertical-scroll-container").pickingMode = PickingMode.Ignore;
m_CategoryListsScrollContainer.contentContainer.pickingMode = PickingMode.Ignore;

m_CategoryListsContainer = new VisualElement { name = "CategoryListsContainer", pickingMode = PickingMode.Ignore };
m_CategoryListsScrollContainer.Add(m_CategoryListsContainer);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ void ClearSelectionWithoutValidation()

VisualElement CreateDummyItemElement()
{
var item = new VisualElement();
var item = new VisualElement { pickingMode = PickingMode.Ignore };
SetupItemElement(item);
return item;
}
Expand Down Expand Up @@ -1905,6 +1905,9 @@ internal class RecycledRow : VisualElement
public RecycledRow(float height)
{
AddToClassList(k_RowUssClassName);

pickingMode = PickingMode.Ignore;

style.height = height;

indices = new List<int>();
Expand Down
5 changes: 5 additions & 0 deletions Editor/SpriteLib/SpriteLibraryEditor/WindowController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ public void RevertChanges()

public void SelectAsset(SpriteLibraryAsset asset, bool modifiedExternally = false)
{
// Only allow .spriteLib files to be used in the editor.
// This is to prevent the user from opening the editor with .psd or .psb containing spriteLibs.
if (!AssetDatabase.GetAssetPath(asset).EndsWith(".spriteLib"))
return;

if (!modifiedExternally)
{
if (asset == null || asset == m_Model.selectedAsset)
Expand Down
9 changes: 8 additions & 1 deletion Editor/SpriteLib/SpriteResolverInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ struct SpriteCategorySelectionList

public void OnEnable()
{
m_SpriteSelectorWidget.Initialize(GetInstanceID());

m_SpriteHash = serializedObject.FindProperty("m_SpriteHash");
m_SpriteKey = serializedObject.FindProperty("m_SpriteKey");
m_LabelHash = serializedObject.FindProperty("m_labelHash");
Expand All @@ -61,6 +63,11 @@ void OnDisable()
EditorApplication.focusChanged -= OnEditorFocusChanged;
}

void OnDestroy()
{
m_SpriteSelectorWidget.Dispose();
}

void SpriteResolverDeserializedCallback()
{
if (!m_IgnoreNextDeserializeCallback)
Expand Down Expand Up @@ -270,7 +277,7 @@ public override void OnInspectorGUI()
}

ApplyModifiedProperty();
if (m_SpriteSelectorWidget.NeedUpdatePreview())
if (m_SpriteSelectorWidget.UpdateSpritePreviews())
this.Repaint();
}

Expand Down
Loading

0 comments on commit 711bf4a

Please sign in to comment.