From 5ac18dbe5c896ab0a8ccb9d1dda314e086a5dce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Teixeira?= Date: Sat, 18 Mar 2017 18:49:44 +1300 Subject: [PATCH] Short-circuit leaderboard window show animation if scores are received Set animation to jump to `show` from any state but `dismiss` if the score are received. It solves a race condition where the scores would be fetched quickly (especially when using caching) and the window would still be appearing and wouldn't listen to the `unlock` (i.e. show) event. Fix #47 and Fix #65 --- .../Animations/GameJoltController.controller | 74 +++++++++++++++---- .../UI/Controllers/LeaderboardsWindow.cs | 2 - Assets/Tests/UI/UI.unity | 12 +++ 3 files changed, 73 insertions(+), 15 deletions(-) diff --git a/Assets/Plugins/GameJolt/Animations/GameJoltController.controller b/Assets/Plugins/GameJolt/Animations/GameJoltController.controller index b1c9b02..6287aeb 100644 --- a/Assets/Plugins/GameJolt/Animations/GameJoltController.controller +++ b/Assets/Plugins/GameJolt/Animations/GameJoltController.controller @@ -13,55 +13,55 @@ AnimatorController: m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} - m_Name: Dismiss m_Type: 9 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} - m_Name: Lock m_Type: 9 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} - m_Name: Unlock m_Type: 9 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} - m_Name: Trophies m_Type: 9 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} - m_Name: ShowLoadingIndicator m_Type: 9 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} - m_Name: HideLoadingIndicator m_Type: 9 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} - m_Name: Leaderboards m_Type: 9 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} - m_Name: Notification m_Type: 9 m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} m_AnimatorLayers: - serializedVersion: 5 m_Name: Base @@ -390,6 +390,29 @@ AnimatorStateTransition: m_InterruptionSource: 0 m_OrderedInterruption: 1 m_CanTransitionToSelf: 1 +--- !u!1101 &110125496 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 1 + m_ConditionEvent: Unlock + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 110203510} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0 + m_TransitionOffset: 0 + m_ExitTime: .875 + m_HasExitTime: 0 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 --- !u!1101 &110127220 AnimatorStateTransition: m_ObjectHideFlags: 1 @@ -479,6 +502,29 @@ AnimatorStateTransition: m_InterruptionSource: 0 m_OrderedInterruption: 1 m_CanTransitionToSelf: 1 +--- !u!1101 &110136088 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 1 + m_ConditionEvent: Unlock + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: 110203510} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0 + m_TransitionOffset: 0 + m_ExitTime: 0 + m_HasExitTime: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 --- !u!1101 &110143312 AnimatorStateTransition: m_ObjectHideFlags: 1 @@ -1071,6 +1117,7 @@ AnimatorState: m_CycleOffset: 0 m_Transitions: - {fileID: 110148476} + - {fileID: 110136088} m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 @@ -1090,6 +1137,7 @@ AnimatorState: m_Transitions: - {fileID: 110143312} - {fileID: 110159544} + - {fileID: 110125496} m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 @@ -1485,13 +1533,13 @@ AnimatorStateMachine: first: {fileID: 110743428} second: [] data: - first: {fileID: 110701254} + first: {fileID: 110797252} second: [] data: - first: {fileID: 110737452} + first: {fileID: 110701254} second: [] data: - first: {fileID: 110797252} + first: {fileID: 110737452} second: [] m_StateMachineBehaviours: [] m_AnyStatePosition: {x: -96, y: 24, z: 0} @@ -1537,7 +1585,7 @@ AnimatorStateMachine: m_ChildStates: - serializedVersion: 1 m_State: {fileID: 110214570} - m_Position: {x: 264, y: 120, z: 0} + m_Position: {x: 264, y: 108, z: 0} - serializedVersion: 1 m_State: {fileID: 110213486} m_Position: {x: 264, y: 216, z: 0} diff --git a/Assets/Plugins/GameJolt/Scripts/UI/Controllers/LeaderboardsWindow.cs b/Assets/Plugins/GameJolt/Scripts/UI/Controllers/LeaderboardsWindow.cs index a62783d..6dfce01 100644 --- a/Assets/Plugins/GameJolt/Scripts/UI/Controllers/LeaderboardsWindow.cs +++ b/Assets/Plugins/GameJolt/Scripts/UI/Controllers/LeaderboardsWindow.cs @@ -43,8 +43,6 @@ override public void Show(Action callback) } } - animator.SetTrigger("Unlock"); - SetScores(); } else diff --git a/Assets/Tests/UI/UI.unity b/Assets/Tests/UI/UI.unity index c285361..fb0f2cd 100644 --- a/Assets/Tests/UI/UI.unity +++ b/Assets/Tests/UI/UI.unity @@ -1169,6 +1169,18 @@ Prefab: propertyPath: m_RootOrder value: 0 objectReference: {fileID: 0} + - target: {fileID: 191248, guid: 7a2e587034d846647b593aa159d7ed8d, type: 2} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 196684, guid: 7a2e587034d846647b593aa159d7ed8d, type: 2} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 124444, guid: 7a2e587034d846647b593aa159d7ed8d, type: 2} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 7a2e587034d846647b593aa159d7ed8d, type: 2} m_IsPrefabParent: 0