Show preview for character when create new char

This commit is contained in:
Le Duc Anh
2026-04-10 15:35:58 +07:00
parent c0f3bc7cfa
commit 1a1c26cf03
13 changed files with 240 additions and 22 deletions
@@ -26,13 +26,13 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4718992442062510477}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalRotation: {x: -0.5, y: 0.5, z: -0.5, w: 0.5}
m_LocalPosition: {x: 0, y: -0.05, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 0, y: 90, z: -90}
--- !u!33 &2161253059558372468
MeshFilter:
m_ObjectHideFlags: 0
@@ -26,13 +26,13 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4382292023794641544}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalRotation: {x: 0, y: 0.7071068, z: 0, w: 0.7071068}
m_LocalPosition: {x: 0.7, y: -0, z: -0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0}
--- !u!33 &5071096693830858488
MeshFilter:
m_ObjectHideFlags: 0
@@ -26,13 +26,13 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 515991963856181584}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalRotation: {x: 0, y: 0, z: 1, w: 0}
m_LocalPosition: {x: 1.21, y: 0, z: -0.1}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 180}
--- !u!33 &576093522017768001
MeshFilter:
m_ObjectHideFlags: 0
@@ -26,13 +26,13 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6256688749818476467}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: 0, y: 0.92387956, z: -0.38268343, w: 0}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 45, y: 180, z: 0}
--- !u!33 &1542721556479386091
MeshFilter:
m_ObjectHideFlags: 0
@@ -26,13 +26,13 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6138653207407383173}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: 0.5, y: 0.5, z: 0.5, w: 0.5}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 0, y: 90, z: 90}
--- !u!33 &6401994335202820992
MeshFilter:
m_ObjectHideFlags: 0
@@ -26,13 +26,13 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2323544904593839448}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalRotation: {x: 0, y: 0, z: -0.7071068, w: 0.7071068}
m_LocalPosition: {x: -1.57, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: -90}
--- !u!33 &8461676310745147242
MeshFilter:
m_ObjectHideFlags: 0
+2 -2
View File
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5fedb46b8c46815ef20d80e72e93f234c41654ea51bee27911deff7bb480572b
size 111019
oid sha256:905756eec7a4d6595fe0f1902981c92a6c6c517aceb389eaa279759cefa07b76
size 112496
@@ -82,7 +82,7 @@ namespace BrewMonster.Scripts
}
}
private void ClearModels()
public void ClearModels()
{
for (int i = 0; i < playerModels.Count; i++)
{
@@ -140,6 +140,7 @@ namespace BrewMonster.Scripts
switch (DataType)
{
case DATA_TYPE.DT_WEAPON_ESSENCE:
if (equipData == null) break;
var weaponData = (WEAPON_ESSENCE)equipData;
string fileModelRight = AFile.NormalizePath(weaponData.FileModelRight, true).ToLower();
@@ -175,6 +176,7 @@ namespace BrewMonster.Scripts
}
break;
case DATA_TYPE.DT_ARMOR_ESSENCE:
if (equipData == null) break;
var pArmor = (ARMOR_ESSENCE)equipData;
var nLocation = pArmor.equip_location;
// BMLogger.Log($"ShowEquipments():: Armor Essence: {pArmor.RealName}");
@@ -10,6 +10,7 @@ using UnityEngine;
using UnityEngine.UI;
using BrewMonster.Scripts;
using BrewMonster.PerfectWorld.Scripts.Utility.ChatFilter;
using System.Collections.Generic;
namespace BrewMonster.UI
{
@@ -29,6 +30,7 @@ namespace BrewMonster.UI
[SerializeField] private Button cancelButton;
[SerializeField] private Button backButton;
[SerializeField] private CDlgMessageBox messageBoxPrefab;
[SerializeField] private PlayerModelPreview playerModelPreview;
private CDlgMessageBox _messageBoxInstance;
private int _currentProfession = -1;
@@ -105,6 +107,8 @@ namespace BrewMonster.UI
ClearValidationError();
UpdateConfirmButtonState();
SetupRoleInfos();
}
public void Hide()
@@ -112,6 +116,14 @@ namespace BrewMonster.UI
gameObject.SetActive(false);
}
public void OnRaceSelected(int prof)
{
if (prof < 0 || prof >= (int)Profession.NUM_PROFESSION) return;
_currentProfession = prof;
OnGenderSelected(GetDefaultGenderForProfession(prof));
}
private void OnProfessionSelected(int profession)
{
if (profession < 0 || profession >= (int)Profession.NUM_PROFESSION)
@@ -180,6 +192,8 @@ namespace BrewMonster.UI
}
UpdateConfirmButtonState();
LoadShowModel(_currentProfession, _currentGender);
}
private void OnConfirmClicked()
@@ -321,5 +335,80 @@ namespace BrewMonster.UI
UpdateConfirmButtonState();
}
}
int[] equipmentIds = new int[]
{
// Set 0
45504, 35751, 35750, 35752, 35749, 0,
// Set 1
36348, 35763, 35762, 35764, 35761, 0,
// Set 2
36353, 35755, 35754, 35756, 35753, 0,
// Set 3
36346, 35747, 35746, 35748, 35745, 0,
// Set 4
45909, 35775, 35774, 35776, 35773, 0,
// Set 5
36354, 35743, 35742, 35744, 35741, 0,
// Set 6
36352, 35739, 35738, 35740, 35737, 42330,
// Set 7
36347, 35771, 35770, 35772, 35769, 42330,
// Set 8
36551, 35767, 35766, 35768, 35765, 0,
// Set 9
36349, 35759, 35758, 35760, 35757, 0,
// Set 10
44959, 45179, 45191, 45215, 45203, 0,
// Set 11
45043, 45170, 45171, 45173, 45172, 0
};
private const int NEWCHAR_WEAPON = 0;
private const int NEWCHAR_UPPERBODY = 1;
private const int NEWCHAR_LOWERBODY = 2;
private const int NEWCHAR_WRIST = 3;
private const int NEWCHAR_FOOT = 4;
private const int NEWCHAR_WING = 5;
private const int NEWCHAR_NUM_EQUIP = 6;
List<RoleInfo> _roleInfos = new();
// Setup all the role infor for the PlayerModelPreview
private void SetupRoleInfos()
{
List<GRoleInventory> equipments = null;
for (int i = 0; i < (int)Profession.NUM_PROFESSION; i++)
{
for (int j = 0; j < (int)Gender.NUM_GENDER; j++)
{
RoleInfo roleInfo = new();
roleInfo.roleid = i * (int)Gender.NUM_GENDER + j;
roleInfo.occupation = (byte)i;
roleInfo.gender = (byte)j;
_roleInfos.Add(roleInfo);
// now we setup the quipment
equipments = new()
{
new GRoleInventory() { id = (uint)equipmentIds[i * 6], pos = NEWCHAR_WEAPON },
new GRoleInventory() { id = (uint)equipmentIds[i * 6 + 1], pos = NEWCHAR_UPPERBODY },
new GRoleInventory() { id = (uint)equipmentIds[i * 6 + 2], pos = NEWCHAR_LOWERBODY },
new GRoleInventory() { id = (uint)equipmentIds[i * 6 + 3], pos = NEWCHAR_WRIST },
new GRoleInventory() { id = (uint)equipmentIds[i * 6 + 4], pos = NEWCHAR_FOOT },
new GRoleInventory() { id = (uint)equipmentIds[i * 6 + 5], pos = NEWCHAR_WING }
};
roleInfo.equipment = equipments;
}
}
playerModelPreview.ShowAllPlayerModels(_roleInfos);
}
private void LoadShowModel(int prof, int gender)
{
playerModelPreview.ShowPlayerModel(prof * (int)Gender.NUM_GENDER + gender);
}
}
}
+111 -1
View File
@@ -240,6 +240,78 @@ MonoBehaviour:
m_ChildScaleWidth: 0
m_ChildScaleHeight: 0
m_ReverseArrangement: 0
--- !u!1 &643220947493540294
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4413492970202972579}
- component: {fileID: 7087868301927233606}
- component: {fileID: 2117175560869302562}
m_Layer: 5
m_Name: Preview
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &4413492970202972579
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 643220947493540294}
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: 3062450172250455840}
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 &7087868301927233606
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 643220947493540294}
m_CullTransparentMesh: 1
--- !u!114 &2117175560869302562
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 643220947493540294}
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 &718756348298879219
GameObject:
m_ObjectHideFlags: 0
@@ -989,6 +1061,18 @@ MonoBehaviour:
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
- m_Target: {fileID: 2842754363616627556}
m_TargetAssemblyTypeName: BrewMonster.UI.CreateCharacterScreen, Assembly-CSharp
m_MethodName: OnRaceSelected
m_Mode: 3
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 6
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_IsOn: 0
--- !u!1 &1325716031922190994
GameObject:
@@ -1319,6 +1403,7 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 687229347454477610}
- {fileID: 4413492970202972579}
- {fileID: 662315717489781323}
- {fileID: 3340562194466076090}
- {fileID: 3790628511968890201}
@@ -1398,6 +1483,7 @@ MonoBehaviour:
cancelButton: {fileID: 3605310658127377634}
backButton: {fileID: 3605310658127377634}
messageBoxPrefab: {fileID: 1069295583529170983, guid: 54cccb2c6a758a24183474cd385ccb2c, type: 3}
playerModelPreview: {fileID: 0}
--- !u!1 &2083311518824170680
GameObject:
m_ObjectHideFlags: 0
@@ -2327,7 +2413,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0.0009808608, y: -0.00012207031}
m_AnchoredPosition: {x: 0.0009808608, y: -0.0004272461}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 1}
--- !u!114 &4021128748820168485
@@ -2626,6 +2712,18 @@ MonoBehaviour:
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
- m_Target: {fileID: 2842754363616627556}
m_TargetAssemblyTypeName: BrewMonster.UI.CreateCharacterScreen, Assembly-CSharp
m_MethodName: OnRaceSelected
m_Mode: 3
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 4
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_IsOn: 0
--- !u!1 &4329002869988547962
GameObject:
@@ -5841,6 +5939,18 @@ MonoBehaviour:
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
- m_Target: {fileID: 2842754363616627556}
m_TargetAssemblyTypeName: BrewMonster.UI.CreateCharacterScreen, Assembly-CSharp
m_MethodName: OnRaceSelected
m_Mode: 3
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_IsOn: 0
--- !u!1 &8955858844608837945
GameObject:
+2 -2
View File
@@ -338,7 +338,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0.0009808608, y: -0.00012207031}
m_SizeDelta: {x: -474.1602, y: -682.9546}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 1}
--- !u!114 &8239567059120679520
MonoBehaviour:
@@ -909,7 +909,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &5968911800527563993
RectTransform:
m_ObjectHideFlags: 0
+5
View File
@@ -402,6 +402,11 @@ namespace BrewMonster
Destroy(m_Wing.gameObject);
m_Wing = null;
}
if (equipData == null)
{
BMLogger.LogError($"ShowEquipments():: Flysword Essence is null: id: {pEquipmentID[i]}");
break;
}
var pFlySword = (FLYSWORD_ESSENCE)equipData;
m_wingType = FlyMode2WingType(pFlySword.fly_mode);
BMLogger.Log($"ShowEquipments():: Flysword Essence: {pFlySword.id} {pFlySword.Name} -- {pFlySword.FileModel}");
+12
View File
@@ -23,11 +23,21 @@ namespace BrewMonster.UI
private CharacterItemUI _selectingCharacterItemUI;
private Action<RoleInfo> _onClickItemChar;
private Action<RoleInfo> _onCreateCharacterComplete;
private List<RoleInfo> _roleInfos;
private void OnEnable()
{
_btnEnterGame.onClick.AddListener(OnClickedEnterGame);
_btnEnterGame.gameObject.SetActive(false);
if (_roleInfos != null && _roleInfos.Count > 0)
{
playerModelPreview?.ShowAllPlayerModels(_roleInfos);
}
else
{
playerModelPreview?.ClearModels();
}
}
private void OnDisable()
@@ -58,6 +68,8 @@ namespace BrewMonster.UI
}
}
_roleInfos = roleInfos;
// Create character items
if (roleInfos != null)
{