From 060ca0f259230e1afafaa5483b6dd5e251129204 Mon Sep 17 00:00:00 2001 From: CroakFang <1605296300@qq.com> Date: Thu, 13 Jul 2023 01:41:59 +0800 Subject: [PATCH] Improve Asset Loading --- .../Animations/SceneTransition_e.anim | 22 +- .../Animations/SceneTransition_s.anim | 22 +- Assets/Scenes/Version2.unity | 722 +++++++++++++++++- Assets/Scripts/UmaAssetManager.cs | 197 +++++ Assets/Scripts/UmaAssetManager.cs.meta | 11 + Assets/Scripts/UmaSceneController.cs | 28 +- Assets/Scripts/UmaViewerBuilder.cs | 222 ++---- Assets/Scripts/UmaViewerMain.cs | 6 +- Assets/Scripts/UmaViewerUI.cs | 18 +- .../Gallop/Live/Cutt/LiveTimelineControl.cs | 2 +- .../Scripts/umamusume/Gallop/Live/Director.cs | 4 +- 11 files changed, 1058 insertions(+), 196 deletions(-) create mode 100644 Assets/Scripts/UmaAssetManager.cs create mode 100644 Assets/Scripts/UmaAssetManager.cs.meta diff --git a/Assets/Resources/Animations/SceneTransition_e.anim b/Assets/Resources/Animations/SceneTransition_e.anim index 8b40bce..b64229f 100644 --- a/Assets/Resources/Animations/SceneTransition_e.anim +++ b/Assets/Resources/Animations/SceneTransition_e.anim @@ -87,7 +87,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 1 + time: 0.8333333 value: 0 inSlope: 0 outSlope: 0 @@ -115,7 +115,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 1 + time: 0.8333333 value: 0.3018868 inSlope: 0 outSlope: 0 @@ -143,7 +143,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 1 + time: 0.8333333 value: 0.3018868 inSlope: 0 outSlope: 0 @@ -171,7 +171,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 1 + time: 0.8333333 value: 0.3018868 inSlope: 0 outSlope: 0 @@ -199,7 +199,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 1 + time: 0.8333333 value: 0 inSlope: 0 outSlope: 0 @@ -228,7 +228,7 @@ AnimationClip: m_AdditiveReferencePoseClip: {fileID: 0} m_AdditiveReferencePoseTime: 0 m_StartTime: 0 - m_StopTime: 1 + m_StopTime: 0.8333333 m_OrientationOffsetY: 0 m_Level: 0 m_CycleOffset: 0 @@ -314,7 +314,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 1 + time: 0.8333333 value: 0 inSlope: 0 outSlope: 0 @@ -342,7 +342,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 1 + time: 0.8333333 value: 0.3018868 inSlope: 0 outSlope: 0 @@ -370,7 +370,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 1 + time: 0.8333333 value: 0.3018868 inSlope: 0 outSlope: 0 @@ -398,7 +398,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 1 + time: 0.8333333 value: 0.3018868 inSlope: 0 outSlope: 0 @@ -426,7 +426,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 1 + time: 0.8333333 value: 0 inSlope: 0 outSlope: 0 diff --git a/Assets/Resources/Animations/SceneTransition_s.anim b/Assets/Resources/Animations/SceneTransition_s.anim index 21a15e7..793de7e 100644 --- a/Assets/Resources/Animations/SceneTransition_s.anim +++ b/Assets/Resources/Animations/SceneTransition_s.anim @@ -87,7 +87,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 1 + time: 0.5 value: 1 inSlope: 0 outSlope: 0 @@ -115,7 +115,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 1 + time: 0.5 value: 0.3018868 inSlope: 0 outSlope: 0 @@ -143,7 +143,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 1 + time: 0.5 value: 0.3018868 inSlope: 0 outSlope: 0 @@ -171,7 +171,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 1 + time: 0.5 value: 0.3018868 inSlope: 0 outSlope: 0 @@ -199,7 +199,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 1 + time: 0.5 value: 1 inSlope: 0 outSlope: 0 @@ -228,7 +228,7 @@ AnimationClip: m_AdditiveReferencePoseClip: {fileID: 0} m_AdditiveReferencePoseTime: 0 m_StartTime: 0 - m_StopTime: 1 + m_StopTime: 0.5 m_OrientationOffsetY: 0 m_Level: 0 m_CycleOffset: 0 @@ -314,7 +314,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 1 + time: 0.5 value: 1 inSlope: 0 outSlope: 0 @@ -342,7 +342,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 1 + time: 0.5 value: 0.3018868 inSlope: 0 outSlope: 0 @@ -370,7 +370,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 1 + time: 0.5 value: 0.3018868 inSlope: 0 outSlope: 0 @@ -398,7 +398,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 1 + time: 0.5 value: 0.3018868 inSlope: 0 outSlope: 0 @@ -426,7 +426,7 @@ AnimationClip: inWeight: 0.33333334 outWeight: 0.33333334 - serializedVersion: 3 - time: 1 + time: 0.5 value: 1 inSlope: 0 outSlope: 0 diff --git a/Assets/Scenes/Version2.unity b/Assets/Scenes/Version2.unity index 22da645..b4905e1 100644 --- a/Assets/Scenes/Version2.unity +++ b/Assets/Scenes/Version2.unity @@ -1528,6 +1528,96 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 67758808} m_CullTransparentMesh: 1 +--- !u!1 &68719412 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 68719413} + - component: {fileID: 68719414} + m_Layer: 0 + m_Name: Slider + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &68719413 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 68719412} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1792169492} + - {fileID: 1950949810} + - {fileID: 283272072} + m_Father: {fileID: 1201479099} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 0} + m_AnchoredPosition: {x: 2.5, y: 10} + m_SizeDelta: {x: -15, y: 20} + m_Pivot: {x: 0.5, y: 0} +--- !u!114 &68719414 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 68719412} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 67db9e8f0e2ae9c40bc1e2b64352a6b4, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 195187058} + m_FillRect: {fileID: 1773836041} + m_HandleRect: {fileID: 195187057} + m_Direction: 0 + m_MinValue: 0 + m_MaxValue: 1 + m_WholeNumbers: 0 + m_Value: 0 + m_OnValueChanged: + m_PersistentCalls: + m_Calls: [] --- !u!1 &69389580 GameObject: m_ObjectHideFlags: 0 @@ -4458,6 +4548,81 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 48} m_Pivot: {x: 0.5, y: 1} +--- !u!1 &195187056 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 195187057} + - component: {fileID: 195187059} + - component: {fileID: 195187058} + m_Layer: 0 + m_Name: Handle + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &195187057 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 195187056} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 283272072} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 20, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &195187058 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 195187056} + m_Enabled: 0 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10913, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &195187059 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 195187056} + m_CullTransparentMesh: 1 --- !u!1 &197132282 GameObject: m_ObjectHideFlags: 0 @@ -4991,8 +5156,9 @@ GameObject: m_Component: - component: {fileID: 217907838} - component: {fileID: 217907837} + - component: {fileID: 217907839} m_Layer: 0 - m_Name: GlobalSceneController + m_Name: GlobalManager m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -5013,6 +5179,9 @@ MonoBehaviour: CavansPrefab: {fileID: 3372298933905795298, guid: 32b4730e27604aa469e71267cc6f70f2, type: 3} CavansInstance: {fileID: 0} + LoadingProgressPanel: {fileID: 1201479098} + LoadingProgressSlider: {fileID: 68719414} + LoadingProgressText: {fileID: 1887055365} --- !u!4 &217907838 Transform: m_ObjectHideFlags: 0 @@ -5023,10 +5192,23 @@ Transform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] + m_Children: + - {fileID: 2136933733} m_Father: {fileID: 0} m_RootOrder: 11 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &217907839 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 217907836} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 48ddc49d7aabf3947bdbcaa84cf080a6, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &232074764 GameObject: m_ObjectHideFlags: 0 @@ -7058,6 +7240,42 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 280814817} m_CullTransparentMesh: 1 +--- !u!1 &283272071 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 283272072} + m_Layer: 0 + m_Name: Handle Slide Area + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &283272072 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 283272071} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 195187057} + m_Father: {fileID: 68719413} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: -20, y: 0} + m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &292348635 GameObject: m_ObjectHideFlags: 0 @@ -16313,7 +16531,7 @@ MonoBehaviour: - m_Target: {fileID: 1564959568} m_TargetAssemblyTypeName: UmaViewerBuilder, umamusume m_MethodName: UnloadAllBundle - m_Mode: 6 + m_Mode: 1 m_Arguments: m_ObjectArgument: {fileID: 0} m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine @@ -33234,6 +33452,83 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1200264882} m_CullTransparentMesh: 1 +--- !u!1 &1201479098 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1201479099} + - component: {fileID: 1201479101} + - component: {fileID: 1201479100} + m_Layer: 0 + m_Name: LoadingBG + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &1201479099 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1201479098} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1887055367} + - {fileID: 68719413} + m_Father: {fileID: 2136933733} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 1, y: 0} + m_AnchorMax: {x: 1, y: 0} + m_AnchoredPosition: {x: -10, y: 10} + m_SizeDelta: {x: 150, y: 50} + m_Pivot: {x: 1, y: 0} +--- !u!114 &1201479100 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1201479098} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.38679248, g: 0.38679248, b: 0.38679248, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1201479101 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1201479098} + m_CullTransparentMesh: 1 --- !u!1 &1202669971 GameObject: m_ObjectHideFlags: 0 @@ -42308,7 +42603,6 @@ MonoBehaviour: MobCharacters: [] Lives: [] Costumes: [] - ShadersLoaded: 0 --- !u!4 &1564959566 Transform: m_ObjectHideFlags: 0 @@ -48910,6 +49204,81 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1771722156} m_CullTransparentMesh: 1 +--- !u!1 &1773836040 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1773836041} + - component: {fileID: 1773836043} + - component: {fileID: 1773836042} + m_Layer: 0 + m_Name: Fill + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1773836041 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1773836040} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1950949810} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1773836042 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1773836040} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1773836043 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1773836040} + m_CullTransparentMesh: 1 --- !u!114 &1775929580 stripped MonoBehaviour: m_CorrespondingSourceObject: {fileID: 2451699974473359926, guid: 14d034506760e5049a12fd1cf057a8b3, @@ -49246,6 +49615,81 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1790151598} m_CullTransparentMesh: 1 +--- !u!1 &1792169491 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1792169492} + - component: {fileID: 1792169494} + - component: {fileID: 1792169493} + m_Layer: 0 + m_Name: Background + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1792169492 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1792169491} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 68719413} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0.25} + m_AnchorMax: {x: 1, y: 0.75} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1792169493 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1792169491} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 0.2901961} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1792169494 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1792169491} + m_CullTransparentMesh: 1 --- !u!1 &1795818864 GameObject: m_ObjectHideFlags: 0 @@ -51837,6 +52281,140 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1883289380} m_CullTransparentMesh: 1 +--- !u!1 &1887055364 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1887055367} + - component: {fileID: 1887055366} + - component: {fileID: 1887055365} + m_Layer: 0 + m_Name: Text (TMP) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1887055365 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1887055364} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: Loading... + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 13 + m_fontSizeBase: 13 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 1 + m_VerticalAlignment: 256 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!222 &1887055366 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1887055364} + m_CullTransparentMesh: 1 +--- !u!224 &1887055367 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1887055364} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1201479099} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -5} + m_SizeDelta: {x: -20, y: 50} + m_Pivot: {x: 0.5, y: 1} --- !u!224 &1887819554 stripped RectTransform: m_CorrespondingSourceObject: {fileID: 22448498, guid: 916ee089a0d7b63419075f91e1c657ec, @@ -53198,6 +53776,42 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1949291610} m_CullTransparentMesh: 1 +--- !u!1 &1950949809 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1950949810} + m_Layer: 0 + m_Name: Fill Area + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1950949810 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1950949809} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1773836041} + m_Father: {fileID: 68719413} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0.25} + m_AnchorMax: {x: 1, y: 0.75} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &1958159929 GameObject: m_ObjectHideFlags: 0 @@ -58949,6 +59563,106 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2135901616} m_CullTransparentMesh: 1 +--- !u!1 &2136933732 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2136933733} + - component: {fileID: 2136933736} + - component: {fileID: 2136933735} + - component: {fileID: 2136933734} + m_Layer: 0 + m_Name: Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2136933733 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2136933732} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_Children: + - {fileID: 1201479099} + m_Father: {fileID: 217907838} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} +--- !u!114 &2136933734 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2136933732} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &2136933735 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2136933732} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 1 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 800, y: 600} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 + m_PresetInfoIsWorld: 0 +--- !u!223 &2136933736 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2136933732} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 0 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_AdditionalShaderChannelsFlag: 25 + m_SortingLayerID: 0 + m_SortingOrder: 5 + m_TargetDisplay: 0 --- !u!1 &2138571369 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/UmaAssetManager.cs b/Assets/Scripts/UmaAssetManager.cs new file mode 100644 index 0000000..cfa2700 --- /dev/null +++ b/Assets/Scripts/UmaAssetManager.cs @@ -0,0 +1,197 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using UnityEngine; + + +public class UmaAssetManager : MonoBehaviour +{ + public static UmaAssetManager instance; + + private Dictionary LoadedBundles = new Dictionary(); + private Dictionary NeverUnload = new Dictionary(); + + public static event Action OnLoadedBundleUpdate; + public static event Action OnLoadedBundleClear; + public static event Action OnLoadProgressChange; + + public static Coroutine LoadCoroutine; + + private void Awake() + { + if (instance) + { + DestroyImmediate(gameObject); + return; + } + instance = this; + DontDestroyOnLoad(this); + } + + public static void PreLoadAndRun(List entries, Action OnDone) + { + if (LoadCoroutine != null) return; + LoadCoroutine = instance.StartCoroutine(instance.PreLoadAsset(entries, OnDone)); + } + + private IEnumerator PreLoadAsset(List entries, Action OnDone) + { + var Main = UmaViewerMain.Instance; + List result = new List(); + foreach (var entry in entries) + { + SearchAB(Main, entry, ref result); + } + + for(int i = 0; i < result.Count; i++) + { + LoadAB(result[i]); + OnLoadProgressChange?.Invoke(i, result.Count); + yield return null; + } + + OnLoadProgressChange?.Invoke(-1, result.Count); + LoadCoroutine = null; + OnDone?.Invoke(); + } + + public static AssetBundle LoadAssetBundle(UmaDatabaseEntry entry, bool neverUnload = false) + { + if (Exist(entry)) return Get(entry); + var Main = UmaViewerMain.Instance; + List result = new List(); + SearchAB(Main, entry, ref result); + foreach(var e in result) + { + LoadAB(e, entry.Name.EndsWith("shader") || neverUnload); + } + return Get(entry.Name); + } + + private static void LoadAB(UmaDatabaseEntry entry, bool neverUnload = false) + { + string filePath = entry.FilePath; + if (Exist(entry.Name)) + { + return; + } + else if (File.Exists(filePath)) + { + + AssetBundle bundle = AssetBundle.LoadFromFile(filePath); + if (!bundle) + { + Debug.Log(filePath + " exists and doesn't work"); + UmaViewerUI.Instance?.ShowMessage(filePath + " exists and doesn't work", UIMessageType.Error); + return; + } + AddOrUpdate(entry.Name, bundle, neverUnload); + if (!neverUnload) + { + OnLoadedBundleUpdate?.Invoke(entry); + } + } + else + { + Debug.LogError($"{entry.Name} - {filePath} does not exist"); + UmaViewerUI.Instance?.ShowMessage($"{entry.Name} - {filePath} does not exist", UIMessageType.Error); + } + } + + private static void SearchAB(UmaViewerMain Main, UmaDatabaseEntry entry,ref List result) + { + if (!string.IsNullOrEmpty(entry.Prerequisites)) + { + foreach (string prerequisite in entry.Prerequisites.Split(';')) + { + if (prerequisite.StartsWith(UmaDatabaseController.CharaPath)) + { + SearchAB(Main , Main.AbChara.FirstOrDefault(ab => ab.Name == prerequisite),ref result); + } + else if (prerequisite.StartsWith(UmaDatabaseController.MotionPath)) + { + SearchAB(Main, Main.AbMotions.FirstOrDefault(ab => ab.Name == prerequisite), ref result); + } + else + SearchAB(Main, Main.AbList.FirstOrDefault(ab => ab.Name == prerequisite), ref result); + } + } + result.Add(entry); + } + + public static AssetBundle Get(string name) => instance.LoadedBundles[name]; + + public static AssetBundle Get(UmaDatabaseEntry entry) => Get(entry.Name); + + public static void AddOrUpdate(string name, AssetBundle bundle, bool neverUnload = false) + { + if (instance.LoadedBundles.ContainsKey(name)) + { + instance.LoadedBundles[name] = bundle; + } + else + { + instance.LoadedBundles.Add(name, bundle); + } + + if (neverUnload) + { + if (instance.NeverUnload.ContainsKey(name)) + { + instance.NeverUnload[name] = bundle; + } + else + { + instance.NeverUnload.Add(name, bundle); + } + } + } + + public static bool Exist(string name) => instance.LoadedBundles.ContainsKey(name) && instance.LoadedBundles[name] != null; + + public static bool Exist(UmaDatabaseEntry entry) => Exist(entry.Name); + + public static bool Exist(AssetBundle bundle) => instance.LoadedBundles.ContainsValue(bundle); + + private static void UnloadBundle(AssetBundle bundle, bool unloadAllObjects) + { + if(instance.NeverUnload.ContainsValue(bundle)) return; + var entry = instance.LoadedBundles.FirstOrDefault(b => b.Value == bundle); + if (entry.Key != null) + { + instance.LoadedBundles.Remove(entry.Key); + } + bundle.Unload(unloadAllObjects); + } + + public static void UnloadAllBundle(bool unloadAllObjects = false) + { + foreach (var bundle in instance.LoadedBundles) + { + if (!instance.NeverUnload.ContainsKey(bundle.Key) && bundle.Value) + { + bundle.Value.Unload(unloadAllObjects); + } + } + + if (unloadAllObjects) + { + var builder = UmaViewerBuilder.Instance; + if (builder) + { + if (builder.CurrentUMAContainer) Destroy(builder.CurrentUMAContainer); + if (builder.CurrentOtherContainer) Destroy(builder.CurrentOtherContainer); + } + } + + instance.LoadedBundles.Clear(); + foreach(var bundle in instance.NeverUnload) + { + instance.LoadedBundles.Add(bundle.Key, bundle.Value); + } + OnLoadedBundleClear?.Invoke(); + } +} + diff --git a/Assets/Scripts/UmaAssetManager.cs.meta b/Assets/Scripts/UmaAssetManager.cs.meta new file mode 100644 index 0000000..e484922 --- /dev/null +++ b/Assets/Scripts/UmaAssetManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 48ddc49d7aabf3947bdbcaa84cf080a6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/UmaSceneController.cs b/Assets/Scripts/UmaSceneController.cs index 5e2646a..087a9f0 100644 --- a/Assets/Scripts/UmaSceneController.cs +++ b/Assets/Scripts/UmaSceneController.cs @@ -1,25 +1,37 @@ using System; using System.Collections; using System.Collections.Generic; +using TMPro; using UnityEngine; using UnityEngine.SceneManagement; +using UnityEngine.UI; public class UmaSceneController:MonoBehaviour { public static UmaSceneController instance; public GameObject CavansPrefab; public GameObject CavansInstance; + + public GameObject LoadingProgressPanel; + public Slider LoadingProgressSlider; + public TextMeshProUGUI LoadingProgressText; + private void Awake() { if (instance) { - Destroy(gameObject); + DestroyImmediate(gameObject); return; } instance = this; DontDestroyOnLoad(this); } + private void Start() + { + UmaAssetManager.OnLoadProgressChange += LoadingProgressChange; + } + public static void LoadScene(string name, Action OnSceneloaded = null, Action OnLastSceneUnloaded = null) { instance.StartCoroutine(instance.LoadLiveSceneAsync(name, OnSceneloaded, OnLastSceneUnloaded)); @@ -58,5 +70,19 @@ public class UmaSceneController:MonoBehaviour yield return new WaitUntil(() => !animation.isPlaying); Destroy(CavansInstance); } + + public void LoadingProgressChange(int curren, int target) + { + if(curren == -1) + { + LoadingProgressPanel.SetActive(false); + } + else + { + LoadingProgressPanel.SetActive(true); + LoadingProgressText.text = $"Loading...({curren}/{target})"; + LoadingProgressSlider.value = (float)curren / target; + } + } } diff --git a/Assets/Scripts/UmaViewerBuilder.cs b/Assets/Scripts/UmaViewerBuilder.cs index 99bde25..f2d1442 100644 --- a/Assets/Scripts/UmaViewerBuilder.cs +++ b/Assets/Scripts/UmaViewerBuilder.cs @@ -44,6 +44,8 @@ public class UmaViewerBuilder : MonoBehaviour public Animator AnimationCameraAnimator; public Camera AnimationCamera; + + private bool ShadersLoaded = false; private void Awake() { Instance = this; @@ -52,11 +54,10 @@ public class UmaViewerBuilder : MonoBehaviour public IEnumerator LoadUma(CharaEntry chara, string costumeId, bool mini) { UnloadUma(); - + UmaAssetManager.UnloadAllBundle(true); int id = chara.Id; CurrentUMAContainer = new GameObject($"Chara_{id}_{costumeId}").AddComponent(); CurrentUMAContainer.CharaEntry = chara; - UnloadAllBundle(); if (mini) { @@ -84,7 +85,7 @@ public class UmaViewerBuilder : MonoBehaviour public void LoadLiveUma(List characters) { - UnloadAllBundle(); + UmaAssetManager.UnloadAllBundle(); for (int i = 0; i < characters.Count; i++) { if (characters[i].CharaEntry.Name != "") @@ -662,7 +663,7 @@ public class UmaViewerBuilder : MonoBehaviour public void LoadProp(UmaDatabaseEntry entry) { UnloadProp(); - UnloadAllBundle(); + UmaAssetManager.UnloadAllBundle(); CurrentOtherContainer = new GameObject(Path.GetFileName(entry.Name)).AddComponent(); RecursiveLoadAsset(entry); @@ -715,7 +716,7 @@ public class UmaViewerBuilder : MonoBehaviour ); } - + //Use CriWare Library /* @@ -871,7 +872,6 @@ public class UmaViewerBuilder : MonoBehaviour public List LoadAudio(UmaDatabaseEntry awb) { List clips = new List(); - UmaViewerUI.Instance.LoadedAssetsAdd(awb); string awbPath = awb.FilePath; if (!File.Exists(awbPath)) return clips; @@ -908,62 +908,30 @@ public class UmaViewerBuilder : MonoBehaviour string lyricsVar = $"live/musicscores/m{songid}/m{songid}_lyrics"; UmaDatabaseEntry lyricsAsset = Main.AbList.FirstOrDefault(a => a.Name.Contains(lyricsVar)); - if (lyricsAsset != null) + AssetBundle bundle = UmaAssetManager.LoadAssetBundle(lyricsAsset); + TextAsset asset = bundle.LoadAsset(Path.GetFileNameWithoutExtension(lyricsVar)); + string[] lines = asset.text.Split("\n"[0]); + + for (int i = 1; i < lines.Length; i++) { - string filePath = lyricsAsset.FilePath; - if (File.Exists(filePath)) + string[] words = lines[i].Split(','); + if (words.Length > 0) { - AssetBundle bundle; - if (Main.LoadedBundles.ContainsKey(lyricsAsset.Name)) + try { - bundle = Main.LoadedBundles[lyricsAsset.Name]; - } - else - { - UI.LoadedAssetsAdd(lyricsAsset); - bundle = AssetBundle.LoadFromFile(filePath); - Main.LoadedBundles.Add(lyricsAsset.Name, bundle); - } - - TextAsset asset = bundle.LoadAsset(Path.GetFileNameWithoutExtension(lyricsVar)); - string[] lines = asset.text.Split("\n"[0]); - - for (int i = 1; i < lines.Length; i++) - { - string[] words = lines[i].Split(','); - if (words.Length > 0) + UmaLyricsData lyricsData = new UmaLyricsData() { - try - { - UmaLyricsData lyricsData = new UmaLyricsData() - { - time = float.Parse(words[0]) / 1000, - text = (words.Length > 1) ? words[1].Replace("[COMMA]", ",") : "" - }; - CurrentLyrics.Add(lyricsData); - } - catch { } - } + time = float.Parse(words[0]) / 1000, + text = (words.Length > 1) ? words[1].Replace("[COMMA]", ",") : "" + }; + CurrentLyrics.Add(lyricsData); } + catch { } } } } - public static AssetBundle LoadOrGet(UmaDatabaseEntry entry) - { - if ((Main.LoadedBundles.ContainsKey(entry.Name))) - { - return Main.LoadedBundles[entry.Name]; - } - else - { - var bundle = AssetBundle.LoadFromFile(entry.FilePath); - Main.LoadedBundles.Add(entry.Name, bundle); - return bundle; - } - } - - public void RecursiveLoadAsset(UmaDatabaseEntry entry, bool IsSubAsset = false, Transform SetParent = null ) + public void RecursiveLoadAsset(UmaDatabaseEntry entry, bool IsSubAsset = false, Transform SetParent = null) { if (!string.IsNullOrEmpty(entry.Prerequisites)) { @@ -987,34 +955,15 @@ public class UmaViewerBuilder : MonoBehaviour public void LoadAsset(UmaDatabaseEntry entry, bool IsSubAsset = false, Transform SetParent = null) { Debug.Log("Loading " + entry.Name); - string filePath = entry.FilePath; - if (Main.LoadedBundles.ContainsKey(entry.Name)) - { - LoadBundle(Main.LoadedBundles[entry.Name], IsSubAsset, SetParent); - } - else if (File.Exists(filePath)) - { - AssetBundle bundle = AssetBundle.LoadFromFile(filePath); - if (bundle == null) - { - Debug.Log(filePath + " exists and doesn't work"); - return; - } - Main.LoadedBundles.Add(entry.Name, bundle); - UI.LoadedAssetsAdd(entry); - LoadBundle(bundle, IsSubAsset, SetParent); - } - else - { - Debug.LogError($"{entry.Name} - {filePath} does not exist"); - } + var bundle = UmaAssetManager.LoadAssetBundle(entry); + LoadBundle(bundle, IsSubAsset, SetParent); } private void LoadBundle(AssetBundle bundle, bool IsSubAsset = false, Transform SetParent = null) { if (bundle.name == "shader.a") { - if (Main.ShadersLoaded) + if (ShadersLoaded) { return; } @@ -1028,7 +977,7 @@ public class UmaViewerBuilder : MonoBehaviour alphaShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/characteralphanolinetoonhairtser.shader"); bodyAlphaShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/characteralphanolinetoontser.shader"); bodyBehindAlphaShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/characteralphanolinetoonbehindtser.shader"); - Main.ShadersLoaded = true; + ShadersLoaded = true; } } @@ -1051,14 +1000,14 @@ public class UmaViewerBuilder : MonoBehaviour { Debug.Log("LiveTime" + UI.LiveTime.ToString()); LoadAnimation(aClip); + break; } if (aClip.name.Contains("tear")) { break; } - - UnloadBundle(bundle, false); + UmaAssetManager.UnloadAllBundle(); break; } case GameObject go: @@ -1496,7 +1445,7 @@ public class UmaViewerBuilder : MonoBehaviour public void LoadAssetPath(string path, Transform SetParent) { - foreach(var asset in UmaViewerMain.Instance.AbList.Where(a => a.Name == path)) + foreach (var asset in UmaViewerMain.Instance.AbList.Where(a => a.Name == path)) { RecursiveLoadAsset(asset, false, SetParent); } @@ -1522,7 +1471,7 @@ public class UmaViewerBuilder : MonoBehaviour { if (!CurrentUMAContainer.Head) return; var locatorEntry = Main.AbList.FirstOrDefault(a => a.Name == "3d/animator/drivenkeylocator"); - var bundle = LoadOrGet(locatorEntry); + var bundle = UmaAssetManager.LoadAssetBundle(locatorEntry); var locator = Instantiate(bundle.LoadAsset("DrivenKeyLocator"), CurrentUMAContainer.transform) as GameObject; locator.name = "DrivenKeyLocator"; @@ -1534,7 +1483,7 @@ public class UmaViewerBuilder : MonoBehaviour var mangaObjects = new List(); mangaEntry.ForEach(entry => { - AssetBundle ab = LoadOrGet(entry); + AssetBundle ab = UmaAssetManager.LoadAssetBundle(entry); var obj = ab.LoadAsset(Path.GetFileNameWithoutExtension(entry.Name)) as GameObject; obj.SetActive(false); @@ -1656,11 +1605,11 @@ public class UmaViewerBuilder : MonoBehaviour if (CurrentUMAContainer.OverrideController["clip_2"].name.Contains("_loop")) { - motion_e = Main.AbMotions.FirstOrDefault(a => + motion_e = Main.AbMotions.FirstOrDefault(a => a.Name.EndsWith(CurrentUMAContainer.OverrideController["clip_2"].name.Replace("_loop", "_e")) && !a.Name.Contains("hom_")); //home end animation not for interpolation - if (motion_e != null) + if (motion_e != null) { RecursiveLoadAsset(motion_e); } @@ -1779,8 +1728,8 @@ public class UmaViewerBuilder : MonoBehaviour if (CurrentUMAContainer.FaceOverrideController["clip_2"].name.Contains("_loop")) { - motion_e = Main.AbMotions.FirstOrDefault(a => - a.Name.EndsWith(CurrentUMAContainer.FaceOverrideController["clip_2"].name.Replace("_loop", "_e")) + motion_e = Main.AbMotions.FirstOrDefault(a => + a.Name.EndsWith(CurrentUMAContainer.FaceOverrideController["clip_2"].name.Replace("_loop", "_e")) && !a.Name.Contains("hom_")); if (motion_e != null) @@ -1824,8 +1773,8 @@ public class UmaViewerBuilder : MonoBehaviour if (CurrentUMAContainer.FaceOverrideController["clip_2_ear"].name.Contains("_loop")) { - motion_e = Main.AbMotions.FirstOrDefault(a => - a.Name.EndsWith(CurrentUMAContainer.FaceOverrideController["clip_2_ear"].name.Replace("_loop", "_e")) + motion_e = Main.AbMotions.FirstOrDefault(a => + a.Name.EndsWith(CurrentUMAContainer.FaceOverrideController["clip_2_ear"].name.Replace("_loop", "_e")) && !a.Name.Contains("hom_")); if (motion_e != null) @@ -1871,50 +1820,19 @@ public class UmaViewerBuilder : MonoBehaviour } } - private void UnloadBundle(AssetBundle bundle, bool unloadAllObjects) - { - var entry = Main.LoadedBundles.FirstOrDefault(b => b.Value == bundle); - if (entry.Key != null) - { - Main.LoadedBundles.Remove(entry.Key); - } - bundle.Unload(unloadAllObjects); - } - - public void UnloadAllBundle(bool unloadAllObjects = false) - { - - foreach (var bundle in Main.LoadedBundles) - { - if (bundle.Value) - bundle.Value.Unload(unloadAllObjects); - } - if (unloadAllObjects) - { - if (CurrentUMAContainer) Destroy(CurrentUMAContainer); - if (CurrentOtherContainer) Destroy(CurrentOtherContainer); - } - Main.LoadedBundles.Clear(); - UI.LoadedAssetsClear(); - } - public Sprite LoadCharaIcon(string id) { string value = $"chara/chr{id}/chr_icon_{id}"; var entry = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name.Equals(value)); - if (entry != null) + if (entry != null) { - string path = entry.FilePath; - if (File.Exists(path)) + AssetBundle assetBundle = UmaAssetManager.LoadAssetBundle(entry, true); + if (assetBundle.Contains($"chr_icon_{id}")) { - AssetBundle assetBundle = AssetBundle.LoadFromFile(path); - if (assetBundle.Contains($"chr_icon_{id}")) - { - Texture2D texture = (Texture2D)assetBundle.LoadAsset($"chr_icon_{id}"); - Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero); - assetBundle.Unload(false); - return sprite; - } + Texture2D texture = (Texture2D)assetBundle.LoadAsset($"chr_icon_{id}"); + Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero); + assetBundle.Unload(false); + return sprite; } } return null; @@ -1926,27 +1844,10 @@ public class UmaViewerBuilder : MonoBehaviour var entry = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name.Equals(value)); if (entry == null) { return null; } string path = entry.FilePath; - if (File.Exists(path)) + AssetBundle assetBundle = UmaAssetManager.LoadAssetBundle(entry, true); + if (assetBundle.Contains($"mob_chr_icon_{id}_000001_01")) { - AssetBundle assetBundle = AssetBundle.LoadFromFile(path); - if (assetBundle.Contains($"mob_chr_icon_{id}_000001_01")) - { - Texture2D texture = (Texture2D)assetBundle.LoadAsset($"mob_chr_icon_{id}_000001_01"); - Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero); - assetBundle.Unload(false); - return sprite; - } - } - return null; - } - - public Sprite LoadSprite(UmaDatabaseEntry item) - { - string path = item.FilePath; - if (File.Exists(path)) - { - AssetBundle assetBundle = AssetBundle.LoadFromFile(path); - Texture2D texture = (Texture2D)assetBundle.LoadAsset(assetBundle.GetAllAssetNames()[0]); + Texture2D texture = (Texture2D)assetBundle.LoadAsset($"mob_chr_icon_{id}_000001_01"); Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero); assetBundle.Unload(false); return sprite; @@ -1954,22 +1855,27 @@ public class UmaViewerBuilder : MonoBehaviour return null; } + public Sprite LoadSprite(UmaDatabaseEntry item) + { + AssetBundle assetBundle = UmaAssetManager.LoadAssetBundle(item, true); + Texture2D texture = (Texture2D)assetBundle.LoadAsset(assetBundle.GetAllAssetNames()[0]); + Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero); + assetBundle.Unload(false); + return sprite; + } + public Sprite LoadLiveIcon(int musicid) { string value = $"live/jacket/jacket_icon_l_{musicid}"; var entry = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name.Equals(value)); if (entry == null) return null; - string path = entry.FilePath; - if (File.Exists(path)) + AssetBundle assetBundle = UmaAssetManager.LoadAssetBundle(entry, true); + if (assetBundle.Contains($"jacket_icon_l_{musicid}")) { - AssetBundle assetBundle = AssetBundle.LoadFromFile(path); - if (assetBundle.Contains($"jacket_icon_l_{musicid}")) - { - Texture2D texture = (Texture2D)assetBundle.LoadAsset($"jacket_icon_l_{musicid}"); - Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero); - assetBundle.Unload(false); - return sprite; - } + Texture2D texture = (Texture2D)assetBundle.LoadAsset($"jacket_icon_l_{musicid}"); + Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero); + assetBundle.Unload(false); + return sprite; } return null; } @@ -1990,12 +1896,12 @@ public class UmaViewerBuilder : MonoBehaviour UmaViewerUI.Instance.currentFaceDrivenKeyTarget = null; UmaViewerUI.Instance.LoadEmotionPanels(null); UmaViewerUI.Instance.LoadFacialPanels(null); - foreach(Transform t in UmaViewerUI.Instance.MaterialsList.content) + foreach (Transform t in UmaViewerUI.Instance.MaterialsList.content) { Destroy(t.gameObject); } - if(CurrentUMAContainer.transform.parent && CurrentUMAContainer.transform.parent.name.Contains("Root")) + if (CurrentUMAContainer.transform.parent && CurrentUMAContainer.transform.parent.name.Contains("Root")) { Destroy(CurrentUMAContainer.transform.parent.gameObject); } @@ -2111,6 +2017,8 @@ public class UmaViewerBuilder : MonoBehaviour } } + public void UnloadAllBundle() => UmaAssetManager.UnloadAllBundle(true); + private void FixedUpdate() { if (AnimationCamera && AnimationCamera.enabled == true) diff --git a/Assets/Scripts/UmaViewerMain.cs b/Assets/Scripts/UmaViewerMain.cs index d657fd6..c4798a7 100644 --- a/Assets/Scripts/UmaViewerMain.cs +++ b/Assets/Scripts/UmaViewerMain.cs @@ -23,10 +23,6 @@ public class UmaViewerMain : MonoBehaviour public List AbEffect = new List(); public List CostumeList = new List(); - [Header("Asset Memory")] - public bool ShadersLoaded = false; - public Dictionary LoadedBundles = new Dictionary(); - private void Awake() { Instance = this; @@ -149,7 +145,7 @@ public class UmaViewerMain : MonoBehaviour string filePath = asset.FilePath; if (File.Exists(filePath)) { - AssetBundle bundle = UmaViewerBuilder.LoadOrGet(asset); + AssetBundle bundle = UmaAssetManager.LoadAssetBundle(asset, true); foreach (var item in UmaDatabaseController.Instance.LiveData) { var musicId = Convert.ToInt32(item["music_id"]); diff --git a/Assets/Scripts/UmaViewerUI.cs b/Assets/Scripts/UmaViewerUI.cs index 322198e..5548e3b 100644 --- a/Assets/Scripts/UmaViewerUI.cs +++ b/Assets/Scripts/UmaViewerUI.cs @@ -157,6 +157,14 @@ public class UmaViewerUI : MonoBehaviour WorkModeDropdown.SetValueWithoutNotify((int)Config.Instance.WorkMode); LanguageDropdown.SetValueWithoutNotify((int)Config.Instance.Language); UpdateDBButton.interactable = (Config.Instance.WorkMode == WorkMode.Standalone); + UmaAssetManager.OnLoadedBundleUpdate += LoadedAssetsAdd; + UmaAssetManager.OnLoadedBundleClear += LoadedAssetsClear; + } + + private void OnDestroy() + { + UmaAssetManager.OnLoadedBundleUpdate -= LoadedAssetsAdd; + UmaAssetManager.OnLoadedBundleClear -= LoadedAssetsClear; } private void Update() @@ -267,7 +275,7 @@ public class UmaViewerUI : MonoBehaviour { if (ui.Name == Path.GetFileName(entry.Name)) return; } - + LoadedAssetCount++; string filePath = entry.FilePath; var container = Instantiate(UmaContainerAssetsPrefab, LoadedAssetsPanel).GetComponent(); @@ -278,6 +286,7 @@ public class UmaViewerUI : MonoBehaviour public void LoadedAssetsClear() { + if (!LoadedAssetsPanel) return; LoadedAssetCount = 0; foreach (UmaUIContainer ui in LoadedAssetsPanel.GetComponentsInChildren()) { @@ -429,7 +438,6 @@ public class UmaViewerUI : MonoBehaviour foreach (var prop in extraMorph.BindProperties) { var container = Instantiate(UmaContainerSliderPrefab, TargetList.content).GetComponent(); - Debug.Log(morph.name); container.Name = $"{morph.locator.name}({prop.Type})"; container.Slider.value = prop.Value; switch (prop.Type) @@ -585,7 +593,6 @@ public class UmaViewerUI : MonoBehaviour } } - public void LoadNormalSoundPanels() { NormalSoundCtrl.Clear(); @@ -737,7 +744,10 @@ public class UmaViewerUI : MonoBehaviour else { HighlightChildImage(costumeList.content, container); - StartCoroutine(Builder.LoadUma(achara, costumeId, mini)); + var list = new List(); + list.AddRange(Main.AbChara.FindAll(a => a.Name.Contains($"{achara.Id}"))); + UmaAssetManager.PreLoadAndRun(list , delegate { StartCoroutine(Builder.LoadUma(achara, costumeId, mini)); }); + //StartCoroutine(Builder.LoadUma(achara, costumeId, mini)); } }); } diff --git a/Assets/Scripts/umamusume/Gallop/Live/Cutt/LiveTimelineControl.cs b/Assets/Scripts/umamusume/Gallop/Live/Cutt/LiveTimelineControl.cs index d13001e..4f9b433 100644 --- a/Assets/Scripts/umamusume/Gallop/Live/Cutt/LiveTimelineControl.cs +++ b/Assets/Scripts/umamusume/Gallop/Live/Cutt/LiveTimelineControl.cs @@ -102,7 +102,7 @@ namespace Gallop.Live.Cutt //Get MotionList foreach (var motion in UmaViewerMain.Instance.AbMotions.Where(a => a.Name.StartsWith($"3d/motion/live/body/son{Director.instance.live.MusicId}") && Path.GetFileName(a.Name).Split('_').Length == 4)) { - AssetBundle motionAB = UmaViewerBuilder.LoadOrGet(motion); + AssetBundle motionAB = UmaAssetManager.LoadAssetBundle(motion); AnimationClip motionAnim = motionAB.LoadAsset(Path.GetFileName(motion.Name).Split('.')[0]); Anims.Add(motionAnim); } diff --git a/Assets/Scripts/umamusume/Gallop/Live/Director.cs b/Assets/Scripts/umamusume/Gallop/Live/Director.cs index fe6981f..7d81d39 100644 --- a/Assets/Scripts/umamusume/Gallop/Live/Director.cs +++ b/Assets/Scripts/umamusume/Gallop/Live/Director.cs @@ -375,7 +375,7 @@ namespace Gallop.Live Debug.Log(partAsset.Name); - AssetBundle bundle = UmaViewerBuilder.LoadOrGet(partAsset); + AssetBundle bundle = UmaAssetManager.LoadAssetBundle(partAsset); TextAsset partData = bundle.LoadAsset($"m{live.MusicId}_part"); partInfo = new PartEntry(partData.text); @@ -534,7 +534,7 @@ namespace Gallop.Live transferObjs.ForEach(o => SceneManager.MoveGameObjectToScene(o, SceneManager.GetSceneByName("Version2"))); }); - AssetBundle.UnloadAllAssetBundles(true); + UmaAssetManager.UnloadAllBundle(true); } if (_isLiveSetup)