改动与优化
This commit is contained in:
@@ -1027,13 +1027,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
|
||||
settingsInstance.SetActive(true);
|
||||
EnsureSettingsLastSibling();
|
||||
RegisterManagedPanel(settingsInstance, () =>
|
||||
{
|
||||
if (settingsInstance != null)
|
||||
{
|
||||
settingsInstance.SetActive(false);
|
||||
}
|
||||
});
|
||||
RegisterManagedPanel(settingsInstance, CloseSettingsWithExitAnim);
|
||||
NotifyManagedPanelVisibilityChanged(true);
|
||||
return;
|
||||
}
|
||||
@@ -1043,23 +1037,41 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
settingsInstance.transform.SetParent(GetSettingsParentTransform(), false);
|
||||
EnsureSettingsLastSibling();
|
||||
|
||||
// Toggle active state
|
||||
bool active = settingsInstance.activeSelf;
|
||||
settingsInstance.SetActive(!active);
|
||||
if (active)
|
||||
{
|
||||
CloseSettingsWithExitAnim();
|
||||
return;
|
||||
}
|
||||
|
||||
settingsInstance.SetActive(true);
|
||||
if (settingsInstance.activeSelf)
|
||||
{
|
||||
EnsureSettingsLastSibling();
|
||||
RegisterManagedPanel(settingsInstance, () =>
|
||||
{
|
||||
if (settingsInstance != null)
|
||||
{
|
||||
settingsInstance.SetActive(false);
|
||||
}
|
||||
});
|
||||
RegisterManagedPanel(settingsInstance, CloseSettingsWithExitAnim);
|
||||
}
|
||||
NotifyManagedPanelVisibilityChanged(true);
|
||||
}
|
||||
|
||||
private void CloseSettingsWithExitAnim()
|
||||
{
|
||||
if (settingsInstance == null)
|
||||
{
|
||||
NotifyManagedPanelVisibilityChanged(true);
|
||||
return;
|
||||
}
|
||||
|
||||
UI_PanelExitUtility.PlayExitThen(settingsInstance, () =>
|
||||
{
|
||||
if (settingsInstance != null)
|
||||
{
|
||||
settingsInstance.SetActive(false);
|
||||
}
|
||||
|
||||
NotifyManagedPanelVisibilityChanged(true);
|
||||
});
|
||||
}
|
||||
|
||||
public bool IsSettingsPanelVisible
|
||||
{
|
||||
get { return settingsInstance != null && settingsInstance.activeInHierarchy; }
|
||||
@@ -1201,8 +1213,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
return;
|
||||
}
|
||||
|
||||
instance.SetActive(false);
|
||||
BroadcastOverlayPanelsVisibility();
|
||||
CloseManagedOverlayWithExitAnim(instance);
|
||||
}
|
||||
|
||||
private bool ToggleIfAlreadyOpen(ref GameObject instance)
|
||||
@@ -1217,8 +1228,7 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
return false;
|
||||
}
|
||||
|
||||
instance.SetActive(false);
|
||||
BroadcastOverlayPanelsVisibility();
|
||||
CloseManagedOverlayWithExitAnim(instance);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1250,12 +1260,34 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
}
|
||||
|
||||
AttachManagedPanelVisibilityRelay(instance, false);
|
||||
EnsurePanelPopupTween(instance);
|
||||
TryAssignCanvasCamera(instance);
|
||||
BroadcastOverlayPanelsVisibility();
|
||||
EnsureTopNavigationFront();
|
||||
return true;
|
||||
}
|
||||
|
||||
private UI_PanelPopupTween EnsurePanelPopupTween(GameObject instance)
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (instance.GetComponent<UI_SettingsPanelEnterAnim>() != null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
UI_PanelPopupTween popupTween = instance.GetComponent<UI_PanelPopupTween>();
|
||||
if (popupTween == null)
|
||||
{
|
||||
popupTween = instance.AddComponent<UI_PanelPopupTween>();
|
||||
}
|
||||
|
||||
return popupTween;
|
||||
}
|
||||
|
||||
private void EnsureSettingsLastSibling()
|
||||
{
|
||||
if (settingsInstance == null || GetSettingsParentTransform() == null)
|
||||
@@ -1296,8 +1328,25 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
private void CloseInstance(ref GameObject instance, GameObject keep)
|
||||
{
|
||||
if (instance == null || instance == keep) return;
|
||||
instance.SetActive(false);
|
||||
BroadcastOverlayPanelsVisibility();
|
||||
CloseManagedOverlayWithExitAnim(instance);
|
||||
}
|
||||
|
||||
private void CloseManagedOverlayWithExitAnim(GameObject instance)
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UI_PanelExitUtility.PlayExitThen(instance, () =>
|
||||
{
|
||||
if (instance != null)
|
||||
{
|
||||
instance.SetActive(false);
|
||||
}
|
||||
|
||||
BroadcastOverlayPanelsVisibility();
|
||||
});
|
||||
}
|
||||
|
||||
private GameObject FindExistingInstance(GameObject prefab)
|
||||
|
||||
Reference in New Issue
Block a user