Author Topic: Suggestion for UISpriteAnimation  (Read 4677 times)

Ironic Chef

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Suggestion for UISpriteAnimation
« on: May 24, 2016, 07:17:40 PM »
I recently needed to have a number of animated sprite objects that used the same looped animation appear side-by-side, but also needed for them to not appear to be identical. I accomplished this by adding a "SetFrame" method to your UISpriteAnimation class that simply changes the value of "mframe" to a specified index. That amounted to three lines of code that allow a UISpriteAnimation to start playing at a different frame. The addition allowed me to alter which frame the animated sprite started at, and made the multiple sprites appear to present different animations using identical frame data.

I really think this is a method that should be added to the UISpriteAnimation class going forward. Currently there is no way to specify the frame on which the animation playback commences. I understand that it's an edge-case issue, but it really is just a few lines of code that extends the functionality of the class in a significant way.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Suggestion for UISpriteAnimation
« Reply #1 on: May 26, 2016, 11:18:10 AM »
Wouldn't it just be easier to make the index public instead?

diederik

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 31
    • View Profile
Re: Suggestion for UISpriteAnimation
« Reply #2 on: August 23, 2016, 04:14:03 AM »
Hi guys,

I saw that this feature was added in 3.9.9. I'm using 3.10.0
I'm not actually using this particular functionality, but I got a warning...

Unable to find property frame
UnityEngine.Debug:LogWarning(Object)
NGUIEditorTools:DrawProperty(String, SerializedObject, String, Boolean, GUILayoutOption[]) (at Assets/NGUI/Scripts/Editor/NGUIEditorTools.cs:1483)
NGUIEditorTools:DrawProperty(String, SerializedObject, String, GUILayoutOption[]) (at Assets/NGUI/Scripts/Editor/NGUIEditorTools.cs:1438)
UISpriteAnimationInspector:OnInspectorGUI() (at Assets/NGUI/Scripts/Editor/UISpriteAnimationInspector.cs:27)
UnityEditor.DockArea:OnGUI()

Looks like the issue was not implemented correctly or not synced between UISpriteAnimation and UISpriteAnimationInspector.
(using the name 'frameIndex' and 'frame')
Was easy to fix though. Just wanted to check if this might need fixing for a future version.

Cheers,

Diederik


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Suggestion for UISpriteAnimation
« Reply #3 on: August 24, 2016, 02:09:01 PM »
Thanks, Diederik. I'll fix it on my end.