update code for logout
This commit is contained in:
@@ -108,12 +108,32 @@ namespace BrewMonster.Scripts
|
||||
}
|
||||
}
|
||||
|
||||
public void HideAllPlayerModels()
|
||||
{
|
||||
_hasRequestedPlayerModelId = false;
|
||||
for (int i = 0; i < playerModels.Count; i++)
|
||||
{
|
||||
if (playerModels[i] != null)
|
||||
{
|
||||
playerModels[i].SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearModels()
|
||||
{
|
||||
//for (int i = 0; i < playerModels.Count; i++)
|
||||
//{
|
||||
// if (playerModels[i] != null)
|
||||
// {
|
||||
// Destroy(playerModels[i]);
|
||||
// }
|
||||
//}
|
||||
|
||||
playerModels.Clear();
|
||||
playerModelIds.Clear();
|
||||
|
||||
if (modelRoot != null)
|
||||
if(modelRoot != null)
|
||||
{
|
||||
foreach (Transform child in modelRoot)
|
||||
{
|
||||
@@ -124,41 +144,39 @@ namespace BrewMonster.Scripts
|
||||
|
||||
private void ClearModelsImmediate()
|
||||
{
|
||||
playerModels.Clear();
|
||||
playerModelIds.Clear();
|
||||
|
||||
if(modelRoot != null)
|
||||
for (int i = 0; i < playerModels.Count; i++)
|
||||
{
|
||||
var children = new Transform[modelRoot.childCount];
|
||||
for (int i = 0; i < modelRoot.childCount; i++)
|
||||
if (modelRoot != null)
|
||||
{
|
||||
children[i] = modelRoot.GetChild(i);
|
||||
}
|
||||
|
||||
foreach (Transform child in children)
|
||||
{
|
||||
if(child != null)
|
||||
if(playerModels[i] != null)
|
||||
{
|
||||
if(Application.isPlaying)
|
||||
Destroy(child.gameObject);
|
||||
Destroy(playerModels[i]);
|
||||
else
|
||||
DestroyImmediate(child.gameObject);
|
||||
DestroyImmediate(playerModels[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
playerModels.Clear();
|
||||
playerModelIds.Clear();
|
||||
}
|
||||
|
||||
private async UniTask<GameObject> LoadPlayerModel(RoleInfo role)
|
||||
{
|
||||
BMLogger.Log($"LoadPlayerModel: {role.roleid}");
|
||||
var elemendataman = BrewMonster.ElementDataManProvider.GetElementDataMan();
|
||||
GameObject prefab = await NPCManager.Instance.GetModelPlayer(role.occupation, role.gender);
|
||||
if (prefab == null)
|
||||
{
|
||||
GameObject model = await NPCManager.Instance.GetModelPlayer(role.occupation, role.gender);
|
||||
if(model == null)
|
||||
return null;
|
||||
}
|
||||
|
||||
model.SetActive(false);
|
||||
BMLogger.Log($"LoadPlayerModel: {role.roleid} - prefab loaded");
|
||||
GameObject model = Instantiate(prefab);
|
||||
if (modelRoot != null)
|
||||
{
|
||||
model.transform.SetParent(modelRoot, false);
|
||||
}
|
||||
|
||||
var playerDefaultEquipments = model.GetComponentInChildren<PlayerDefaultEquipments>();
|
||||
if (playerDefaultEquipments == null)
|
||||
{
|
||||
|
||||
@@ -56,6 +56,11 @@ namespace BrewMonster.UI
|
||||
{
|
||||
Tech3CSDKWrapper.Instance.SetLoginCallback(OnLoginCallback);
|
||||
Tech3CSDKWrapper.Instance.SetLogoutCallback(OnLogoutCallback);
|
||||
|
||||
if(PlayerModelPreview.Instance != null)
|
||||
{
|
||||
PlayerModelPreview.Instance.HideAllPlayerModels();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
|
||||
@@ -243,6 +243,11 @@ namespace BrewMonster.UI
|
||||
{
|
||||
_onExit?.Invoke();
|
||||
gameObject.SetActive(false);
|
||||
|
||||
if(PlayerModelPreview.Instance != null)
|
||||
{
|
||||
PlayerModelPreview.Instance.HideAllPlayerModels();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user