From 20c1a7cfc4e89b254159798591e3f85ffda6b90c Mon Sep 17 00:00:00 2001 From: Le Duc Anh Date: Fri, 3 Apr 2026 16:33:30 +0700 Subject: [PATCH] add char preview in login screen --- .../tcks_2014新种族巧匠/empty.anim | 53 +++++++++ .../tcks_2014新种族巧匠/empty.anim.meta | 8 ++ .../tcks_2014新种族巧匠.controller | 31 ++++- .../躯干/tcks_妖兽男/tcks_妖兽男 1.controller | 2 +- .../npcs/npc/2013把式艺人/13把式艺人.prefab | 2 +- .../npc/2014新种族巧匠/2014新种族巧匠.prefab | 29 ++--- .../models/npcs/npc/女npc14/女npc14.prefab | 6 +- .../players/形象/妖兽男/躯干/妖兽男.prefab | 2 +- .../UI/LoginScreenCharacterRT.renderTexture | 39 +++++++ .../LoginScreenCharacterRT.renderTexture.meta | 8 ++ Assets/PerfectWorld/Scene/LoginScene.unity | 4 +- .../Scripts/Players/PlayerModelPreview.cs | 108 ++++++++++++++++++ .../Players/PlayerModelPreview.cs.meta | 2 + Assets/Prefabs/UI/SelectCharacterUI.prefab | 74 ++++++++++++ Assets/Scripts/SelecScreenCharacter.cs | 13 +++ 15 files changed, 354 insertions(+), 27 deletions(-) create mode 100644 Assets/ModelRenderer/Art/Animations/models/npcs/npc/2014新种族巧匠/tcks_2014新种族巧匠/empty.anim create mode 100644 Assets/ModelRenderer/Art/Animations/models/npcs/npc/2014新种族巧匠/tcks_2014新种族巧匠/empty.anim.meta create mode 100644 Assets/PerfectWorld/Resources/UI/LoginScreenCharacterRT.renderTexture create mode 100644 Assets/PerfectWorld/Resources/UI/LoginScreenCharacterRT.renderTexture.meta create mode 100644 Assets/PerfectWorld/Scripts/Players/PlayerModelPreview.cs create mode 100644 Assets/PerfectWorld/Scripts/Players/PlayerModelPreview.cs.meta diff --git a/Assets/ModelRenderer/Art/Animations/models/npcs/npc/2014新种族巧匠/tcks_2014新种族巧匠/empty.anim b/Assets/ModelRenderer/Art/Animations/models/npcs/npc/2014新种族巧匠/tcks_2014新种族巧匠/empty.anim new file mode 100644 index 0000000000..584aa3d64e --- /dev/null +++ b/Assets/ModelRenderer/Art/Animations/models/npcs/npc/2014新种族巧匠/tcks_2014新种族巧匠/empty.anim @@ -0,0 +1,53 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!74 &7400000 +AnimationClip: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: empty + serializedVersion: 7 + m_Legacy: 0 + m_Compressed: 0 + m_UseHighQualityCurve: 1 + m_RotationCurves: [] + m_CompressedRotationCurves: [] + m_EulerCurves: [] + m_PositionCurves: [] + m_ScaleCurves: [] + m_FloatCurves: [] + m_PPtrCurves: [] + m_SampleRate: 60 + m_WrapMode: 0 + m_Bounds: + m_Center: {x: 0, y: 0, z: 0} + m_Extent: {x: 0, y: 0, z: 0} + m_ClipBindingConstant: + genericBindings: [] + pptrCurveMapping: [] + m_AnimationClipSettings: + serializedVersion: 2 + m_AdditiveReferencePoseClip: {fileID: 0} + m_AdditiveReferencePoseTime: 0 + m_StartTime: 0 + m_StopTime: 1 + m_OrientationOffsetY: 0 + m_Level: 0 + m_CycleOffset: 0 + m_HasAdditiveReferencePose: 0 + m_LoopTime: 0 + m_LoopBlend: 0 + m_LoopBlendOrientation: 0 + m_LoopBlendPositionY: 0 + m_LoopBlendPositionXZ: 0 + m_KeepOriginalOrientation: 0 + m_KeepOriginalPositionY: 1 + m_KeepOriginalPositionXZ: 0 + m_HeightFromFeet: 0 + m_Mirror: 0 + m_EditorCurves: [] + m_EulerEditorCurves: [] + m_HasGenericRootTransform: 0 + m_HasMotionFloatCurves: 0 + m_Events: [] diff --git a/Assets/ModelRenderer/Art/Animations/models/npcs/npc/2014新种族巧匠/tcks_2014新种族巧匠/empty.anim.meta b/Assets/ModelRenderer/Art/Animations/models/npcs/npc/2014新种族巧匠/tcks_2014新种族巧匠/empty.anim.meta new file mode 100644 index 0000000000..5cb518bf7a --- /dev/null +++ b/Assets/ModelRenderer/Art/Animations/models/npcs/npc/2014新种族巧匠/tcks_2014新种族巧匠/empty.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5ec58c5879c1b944e9ffe75104d09a69 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 7400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ModelRenderer/Art/Animations/models/npcs/npc/2014新种族巧匠/tcks_2014新种族巧匠/tcks_2014新种族巧匠.controller b/Assets/ModelRenderer/Art/Animations/models/npcs/npc/2014新种族巧匠/tcks_2014新种族巧匠/tcks_2014新种族巧匠.controller index f3240490d3..72ba8ef2f9 100644 --- a/Assets/ModelRenderer/Art/Animations/models/npcs/npc/2014新种族巧匠/tcks_2014新种族巧匠/tcks_2014新种族巧匠.controller +++ b/Assets/ModelRenderer/Art/Animations/models/npcs/npc/2014新种族巧匠/tcks_2014新种族巧匠/tcks_2014新种族巧匠.controller @@ -30,6 +30,9 @@ AnimatorStateMachine: - serializedVersion: 1 m_State: {fileID: -4168332861537921842} m_Position: {x: 410, y: 390, z: 0} + - serializedVersion: 1 + m_State: {fileID: -5604009941558051294} + m_Position: {x: 173, y: 281, z: 0} m_ChildStateMachines: [] m_AnyStateTransitions: [] m_EntryTransitions: [] @@ -39,7 +42,7 @@ AnimatorStateMachine: m_EntryPosition: {x: 50, y: 120, z: 0} m_ExitPosition: {x: 800, y: 120, z: 0} m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} - m_DefaultState: {fileID: 4680987466827899697} + m_DefaultState: {fileID: -5604009941558051294} --- !u!1102 &-8169011669238131426 AnimatorState: serializedVersion: 6 @@ -66,6 +69,32 @@ AnimatorState: m_MirrorParameter: m_CycleOffsetParameter: m_TimeParameter: +--- !u!1102 &-5604009941558051294 +AnimatorState: + serializedVersion: 6 + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: empty + m_Speed: 1 + m_CycleOffset: 0 + m_Transitions: [] + m_StateMachineBehaviours: [] + m_Position: {x: 50, y: 50, z: 0} + m_IKOnFeet: 0 + m_WriteDefaultValues: 1 + m_Mirror: 0 + m_SpeedParameterActive: 0 + m_MirrorParameterActive: 0 + m_CycleOffsetParameterActive: 0 + m_TimeParameterActive: 0 + m_Motion: {fileID: 7400000, guid: 5ec58c5879c1b944e9ffe75104d09a69, type: 2} + m_Tag: + m_SpeedParameter: + m_MirrorParameter: + m_CycleOffsetParameter: + m_TimeParameter: --- !u!1102 &-4168332861537921842 AnimatorState: serializedVersion: 6 diff --git a/Assets/ModelRenderer/Art/Animations/models/players/形象/妖兽男/躯干/tcks_妖兽男/tcks_妖兽男 1.controller b/Assets/ModelRenderer/Art/Animations/models/players/形象/妖兽男/躯干/tcks_妖兽男/tcks_妖兽男 1.controller index 5f5d24b32a..ae53eb7308 100644 --- a/Assets/ModelRenderer/Art/Animations/models/players/形象/妖兽男/躯干/tcks_妖兽男/tcks_妖兽男 1.controller +++ b/Assets/ModelRenderer/Art/Animations/models/players/形象/妖兽男/躯干/tcks_妖兽男/tcks_妖兽男 1.controller @@ -64,7 +64,7 @@ AnimatorState: m_MirrorParameterActive: 0 m_CycleOffsetParameterActive: 0 m_TimeParameterActive: 0 - m_Motion: {fileID: 7400000, guid: 2d078e760e20f8a408d08a742ee73a12, type: 2} + m_Motion: {fileID: 7400000, guid: 217896426b9421043b9d831f475d7fd6, type: 2} m_Tag: m_SpeedParameter: m_MirrorParameter: diff --git a/Assets/ModelRenderer/Art/Models/models/npcs/npc/2013把式艺人/13把式艺人.prefab b/Assets/ModelRenderer/Art/Models/models/npcs/npc/2013把式艺人/13把式艺人.prefab index e53da714e1..6ed4b9c98d 100644 --- a/Assets/ModelRenderer/Art/Models/models/npcs/npc/2013把式艺人/13把式艺人.prefab +++ b/Assets/ModelRenderer/Art/Models/models/npcs/npc/2013把式艺人/13把式艺人.prefab @@ -2178,7 +2178,7 @@ Transform: m_GameObject: {fileID: 5309046727013202809} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0.012923843, y: -1.3504136, z: -0.4613162} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: diff --git a/Assets/ModelRenderer/Art/Models/models/npcs/npc/2014新种族巧匠/2014新种族巧匠.prefab b/Assets/ModelRenderer/Art/Models/models/npcs/npc/2014新种族巧匠/2014新种族巧匠.prefab index 708fe8261b..dfd74fa42b 100644 --- a/Assets/ModelRenderer/Art/Models/models/npcs/npc/2014新种族巧匠/2014新种族巧匠.prefab +++ b/Assets/ModelRenderer/Art/Models/models/npcs/npc/2014新种族巧匠/2014新种族巧匠.prefab @@ -327,7 +327,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 683691332668038506} serializedVersion: 2 - m_LocalRotation: {x: -0.11101045, y: -0.04166929, z: -0.5077211, w: 0.8533228} + m_LocalRotation: {x: -0.11101045, y: -0.041669287, z: -0.5077211, w: 0.8533227} m_LocalPosition: {x: 0.09138348, y: -0.0000002315723, z: 0.000000084809784} m_LocalScale: {x: 1, y: 1, z: 0.99999994} m_ConstrainProportionsScale: 0 @@ -584,9 +584,9 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2766410454018355639} serializedVersion: 2 - m_LocalRotation: {x: -0.49705055, y: -0.50293314, z: 0.50293213, w: 0.49704963} - m_LocalPosition: {x: -2.4329233e-27, y: 2.0678083e-25, z: -3.287398e-11} - m_LocalScale: {x: 0.99999994, y: 1, z: 1} + 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_ConstrainProportionsScale: 0 m_Children: - {fileID: 4351620120512775520} @@ -774,7 +774,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 4720879457648212373} serializedVersion: 2 - m_LocalRotation: {x: 0.024982965, y: 0.00096658804, z: -0.9989833, w: 0.037512425} + m_LocalRotation: {x: 0.024982966, y: 0.0009665881, z: -0.9989834, w: 0.03751243} m_LocalPosition: {x: -0.08085043, y: -0.07029506, z: -0.013821308} m_LocalScale: {x: 0.9999999, y: 0.99999994, z: 0.99999994} m_ConstrainProportionsScale: 0 @@ -1493,7 +1493,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 7384772661047576604} serializedVersion: 2 - m_LocalRotation: {x: -0.00038805598, y: -0.22343403, z: 0.00008893757, w: 0.97471905} + m_LocalRotation: {x: -0.000388056, y: -0.22343402, z: 0.00008893758, w: 0.974719} m_LocalPosition: {x: 0.08985962, y: 0.018896379, z: -0.0053303735} m_LocalScale: {x: 1, y: 0.9999999, z: 1} m_ConstrainProportionsScale: 0 @@ -1636,7 +1636,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 3432869450322735176} - - component: {fileID: 8487291170773602984} + - component: {fileID: 7911336747716875204} m_Layer: 0 m_Name: "2014\u65B0\u79CD\u65CF\u5DE7\u5320" m_TagString: Untagged @@ -1660,7 +1660,7 @@ Transform: - {fileID: 4714765410777422588} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &8487291170773602984 +--- !u!114 &7911336747716875204 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -1675,14 +1675,7 @@ MonoBehaviour: _Animator: {fileID: 4328270040671007892} _ActionOnDisable: 0 _PlayAutomatically: 1 - _Animations: - - {fileID: 7400000, guid: ff7f1e5e882324a469a70cfefa9c815e, type: 2} - - {fileID: 7400000, guid: 171b0c7c8f63347439332ac5c833d337, type: 2} - - {fileID: 7400000, guid: 20a8352695b4d4a6d8ed1cf119af9ccf, type: 2} - - {fileID: 7400000, guid: 03d1d0dceb1e74cbfaca89d2783d7319, type: 2} - - {fileID: 7400000, guid: 9cbe42f89845e4b31af0b10e6cf274a2, type: 2} - - {fileID: 7400000, guid: bde667d51444f4e6b94641f17deaf307, type: 2} - - {fileID: 7400000, guid: eeaa622c67e5c480dbc95a8074b5c38f, type: 2} + _Animations: [] --- !u!1 &7981313314164196668 GameObject: m_ObjectHideFlags: 0 @@ -1770,7 +1763,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 8647186964427882809} serializedVersion: 2 - m_LocalRotation: {x: 0.07870702, y: -0.078707896, z: -0.7027125, w: 0.70271283} + m_LocalRotation: {x: 0.078707024, y: -0.0787079, z: -0.70271254, w: 0.7027129} m_LocalPosition: {x: -1.0297341, y: -0.0000007519037, z: -0.2618062} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 @@ -1836,7 +1829,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 8716198479051244947} serializedVersion: 2 - m_LocalRotation: {x: -0.50000006, y: 0.49999994, z: 0.49999988, w: 0.50000006} + m_LocalRotation: {x: -0.5000001, y: 0.49999997, z: 0.4999999, w: 0.5000001} m_LocalPosition: {x: 0.81044877, y: 0.19025493, z: -0.18675323} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 diff --git a/Assets/ModelRenderer/Art/Models/models/npcs/npc/女npc14/女npc14.prefab b/Assets/ModelRenderer/Art/Models/models/npcs/npc/女npc14/女npc14.prefab index 4113bf3b8e..a37f2214c4 100644 --- a/Assets/ModelRenderer/Art/Models/models/npcs/npc/女npc14/女npc14.prefab +++ b/Assets/ModelRenderer/Art/Models/models/npcs/npc/女npc14/女npc14.prefab @@ -120,8 +120,8 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1365927648587094752} serializedVersion: 2 - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0.012923843, y: -1.3504136, z: -0.4613162} + 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_ConstrainProportionsScale: 0 m_Children: @@ -130,7 +130,7 @@ Transform: - {fileID: 5081897400159099243} - {fileID: 6219556052433732146} m_Father: {fileID: 4511886399783565272} - m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!95 &7617229724733668831 Animator: serializedVersion: 7 diff --git a/Assets/ModelRenderer/Art/Models/models/players/形象/妖兽男/躯干/妖兽男.prefab b/Assets/ModelRenderer/Art/Models/models/players/形象/妖兽男/躯干/妖兽男.prefab index 2f8ab1a903..997a217bbc 100644 --- a/Assets/ModelRenderer/Art/Models/models/players/形象/妖兽男/躯干/妖兽男.prefab +++ b/Assets/ModelRenderer/Art/Models/models/players/形象/妖兽男/躯干/妖兽男.prefab @@ -2001,7 +2001,7 @@ MonoBehaviour: _ActionOnDisable: 0 _PlayAutomatically: 1 _Animations: - - {fileID: 7400000, guid: 01a151ebb1153164180c7daceca0c369, type: 2} + - {fileID: 7400000, guid: d41c0ac6d2feb814fa5909eee11f08a1, type: 2} - {fileID: 7400000, guid: 980ce179e505aeb4a890c294faa12d09, type: 2} - {fileID: 7400000, guid: 38722ca2f20193d46a2ec001ba821bf4, type: 2} - {fileID: 7400000, guid: 20c7d8667e95984498389bc2fcac0eb9, type: 2} diff --git a/Assets/PerfectWorld/Resources/UI/LoginScreenCharacterRT.renderTexture b/Assets/PerfectWorld/Resources/UI/LoginScreenCharacterRT.renderTexture new file mode 100644 index 0000000000..4accc2f58e --- /dev/null +++ b/Assets/PerfectWorld/Resources/UI/LoginScreenCharacterRT.renderTexture @@ -0,0 +1,39 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!84 &8400000 +RenderTexture: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: LoginScreenCharacterRT + m_ImageContentsHash: + serializedVersion: 2 + Hash: 00000000000000000000000000000000 + m_IsAlphaChannelOptional: 0 + serializedVersion: 6 + m_Width: 512 + m_Height: 512 + m_AntiAliasing: 1 + m_MipCount: -1 + m_DepthStencilFormat: 90 + m_ColorFormat: 12 + m_MipMap: 0 + m_GenerateMips: 1 + m_SRGB: 0 + m_UseDynamicScale: 0 + m_UseDynamicScaleExplicit: 0 + m_BindMS: 0 + m_EnableCompatibleFormat: 1 + m_EnableRandomWrite: 0 + m_TextureSettings: + serializedVersion: 2 + m_FilterMode: 0 + m_Aniso: 0 + m_MipBias: 0 + m_WrapU: 1 + m_WrapV: 1 + m_WrapW: 1 + m_Dimension: 2 + m_VolumeDepth: 1 + m_ShadowSamplingMode: 2 diff --git a/Assets/PerfectWorld/Resources/UI/LoginScreenCharacterRT.renderTexture.meta b/Assets/PerfectWorld/Resources/UI/LoginScreenCharacterRT.renderTexture.meta new file mode 100644 index 0000000000..5520f6eb59 --- /dev/null +++ b/Assets/PerfectWorld/Resources/UI/LoginScreenCharacterRT.renderTexture.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7b35d3c1ebbb32d47a5ed61606928730 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 8400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PerfectWorld/Scene/LoginScene.unity b/Assets/PerfectWorld/Scene/LoginScene.unity index 41fd65b332..671c351f6e 100644 --- a/Assets/PerfectWorld/Scene/LoginScene.unity +++ b/Assets/PerfectWorld/Scene/LoginScene.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4b854fd255462f21d3b44d27526138345930a673f5c74cd2c1ca261ebd834048 -size 106212 +oid sha256:5fedb46b8c46815ef20d80e72e93f234c41654ea51bee27911deff7bb480572b +size 111019 diff --git a/Assets/PerfectWorld/Scripts/Players/PlayerModelPreview.cs b/Assets/PerfectWorld/Scripts/Players/PlayerModelPreview.cs new file mode 100644 index 0000000000..7724b5e1d1 --- /dev/null +++ b/Assets/PerfectWorld/Scripts/Players/PlayerModelPreview.cs @@ -0,0 +1,108 @@ +using System.Collections.Generic; +using BrewMonster.Scripts.Managers; +using CSNetwork.Protocols.RPCData; +using UnityEngine; + +namespace BrewMonster.Scripts +{ + public class PlayerModelPreview : MonoBehaviour + { + [SerializeField] private Transform modelRoot; + + public List playerModels = new(); + public List playerModelIds = new(); + + private int _loadVersion; + + private void Awake() + { + if (modelRoot == null) + modelRoot = transform; + } + + private void OnDestroy() + { + ClearModelsImmediate(); + } + + /// + /// Loads one preview instance per role (via ). + /// All instances stay hidden until is called. + /// + public async void ShowAllPlayerModels(List roleInfos) + { + _loadVersion++; + int version = _loadVersion; + + ClearModels(); + + if (roleInfos == null || roleInfos.Count == 0 || NPCManager.Instance == null) + return; + + for (int i = 0; i < roleInfos.Count; i++) + { + RoleInfo role = roleInfos[i]; + GameObject model = await NPCManager.Instance.GetModelPlayer(role.occupation, role.gender); + + if (version != _loadVersion) + { + if (model != null) + Destroy(model); + return; + } + + if (model == null) + continue; + + model.transform.SetParent(modelRoot, false); + model.transform.localPosition = Vector3.zero; + model.transform.localRotation = Quaternion.identity; + model.SetActive(false); + playerModels.Add(model); + playerModelIds.Add(role.roleid); + } + } + + /// + /// Shows the preview for the given role id (matches ). Hides all others. + /// + public void ShowPlayerModel(int playerModelId) + { + int n = Mathf.Min(playerModels.Count, playerModelIds.Count); + for (int i = 0; i < n; i++) + { + GameObject go = playerModels[i]; + if (go == null) + continue; + go.SetActive(playerModelIds[i] == playerModelId); + } + } + + private void ClearModels() + { + for (int i = 0; i < playerModels.Count; i++) + { + if (playerModels[i] != null) + Destroy(playerModels[i]); + } + playerModels.Clear(); + playerModelIds.Clear(); + } + + private void ClearModelsImmediate() + { + for (int i = 0; i < playerModels.Count; i++) + { + if (playerModels[i] != null) + { + if (Application.isPlaying) + Destroy(playerModels[i]); + else + DestroyImmediate(playerModels[i]); + } + } + playerModels.Clear(); + playerModelIds.Clear(); + } + } +} diff --git a/Assets/PerfectWorld/Scripts/Players/PlayerModelPreview.cs.meta b/Assets/PerfectWorld/Scripts/Players/PlayerModelPreview.cs.meta new file mode 100644 index 0000000000..6dd64a5bbb --- /dev/null +++ b/Assets/PerfectWorld/Scripts/Players/PlayerModelPreview.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 23db063ab37a953418e01ed3b67c0134 \ No newline at end of file diff --git a/Assets/Prefabs/UI/SelectCharacterUI.prefab b/Assets/Prefabs/UI/SelectCharacterUI.prefab index 384c711492..888f31fbe9 100644 --- a/Assets/Prefabs/UI/SelectCharacterUI.prefab +++ b/Assets/Prefabs/UI/SelectCharacterUI.prefab @@ -516,6 +516,78 @@ MonoBehaviour: m_hasFontAssetChanged: 0 m_baseMaterial: {fileID: 0} m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!1 &4802983704394444715 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7742996028187596120} + - component: {fileID: 8266368899107907004} + - component: {fileID: 4268845758980371891} + m_Layer: 5 + m_Name: Preview + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &7742996028187596120 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4802983704394444715} + 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_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 5968911800527563993} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 1024, y: 1024} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &8266368899107907004 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4802983704394444715} + m_CullTransparentMesh: 1 +--- !u!114 &4268845758980371891 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4802983704394444715} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, 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_Texture: {fileID: 8400000, guid: 7b35d3c1ebbb32d47a5ed61606928730, type: 2} + m_UVRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 --- !u!1 &4925246028977896636 GameObject: m_ObjectHideFlags: 0 @@ -854,6 +926,7 @@ RectTransform: - {fileID: 8811543958641262336} - {fileID: 8724103834249725641} - {fileID: 8190183238285994582} + - {fileID: 7742996028187596120} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} @@ -917,6 +990,7 @@ MonoBehaviour: createCharacterButton: {fileID: 2685968509838782728} _btnEnterGame: {fileID: 5173447691193350084} createCharacterScreen: {fileID: 0} + playerModelPreview: {fileID: 0} --- !u!1 &7510180475820570348 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/SelecScreenCharacter.cs b/Assets/Scripts/SelecScreenCharacter.cs index 01ea439c40..209b7b8d9d 100644 --- a/Assets/Scripts/SelecScreenCharacter.cs +++ b/Assets/Scripts/SelecScreenCharacter.cs @@ -1,12 +1,15 @@ using CSNetwork.Protocols.RPCData; using System; using System.Collections.Generic; +using BrewMonster.Scripts; using UnityEngine; using UnityEngine.UI; using BrewMonster; namespace BrewMonster.UI { + // Select Character Screen + //TODO: Change the name to SelectCharacterScreen public class SelecScreenCharacter : MonoBehaviour { [SerializeField] private GameObject characterItemPrefab; @@ -15,6 +18,7 @@ namespace BrewMonster.UI [SerializeField] private Button createCharacterButton; [SerializeField] private Button _btnEnterGame; [SerializeField] private CreateCharacterScreen createCharacterScreen; + [SerializeField] private PlayerModelPreview playerModelPreview; private CharacterItemUI _selectingCharacterItemUI; private Action _onClickItemChar; @@ -91,6 +95,7 @@ namespace BrewMonster.UI addButton.onClick.AddListener(OnCreateCharacterClicked); } } + } else { @@ -100,9 +105,14 @@ namespace BrewMonster.UI createCharacterButton.gameObject.SetActive(true); } } + + // Load player preview 3D models + playerModelPreview?.ShowAllPlayerModels(roleInfos); } else { + if (playerModelPreview != null) + playerModelPreview.ShowAllPlayerModels(null); // If roleInfos is null, show createCharacterButton if (createCharacterButton != null) { @@ -126,6 +136,9 @@ namespace BrewMonster.UI _selectingCharacterItemUI = characterItemUI; _selectingCharacterItemUI.SetFocus(true); _btnEnterGame.gameObject.SetActive(true); + + if (playerModelPreview != null && characterItemUI.RoleInfo != null) + playerModelPreview.ShowPlayerModel(characterItemUI.RoleInfo.roleid); } private void OnCreateCharacterClicked()