通用load
This commit is contained in:
parent
3a988ee540
commit
421fc39ede
@ -850,8 +850,8 @@ RectTransform:
|
|||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 1}
|
m_AnchorMin: {x: 0, y: 1}
|
||||||
m_AnchorMax: {x: 0, y: 1}
|
m_AnchorMax: {x: 0, y: 1}
|
||||||
m_AnchoredPosition: {x: 462.18054, y: -1101.9258}
|
m_AnchoredPosition: {x: 462.18054, y: -1051.9258}
|
||||||
m_SizeDelta: {x: 725.2872, y: 0}
|
m_SizeDelta: {x: 0, y: 0}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!114 &5361498673185763723
|
--- !u!114 &5361498673185763723
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
|
8
meng_yao/Assets/Prefabs/ui/load.meta
Normal file
8
meng_yao/Assets/Prefabs/ui/load.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c54423c9f9fd926409e5a673ad9b4282
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
213
meng_yao/Assets/Prefabs/ui/load/loadingPanel.prefab
Normal file
213
meng_yao/Assets/Prefabs/ui/load/loadingPanel.prefab
Normal file
@ -0,0 +1,213 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &6870665345490481988
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 6870665345490481989}
|
||||||
|
- component: {fileID: 6870665345490481995}
|
||||||
|
- component: {fileID: 6870665345490481994}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: Text (Legacy)
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &6870665345490481989
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6870665345490481988}
|
||||||
|
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: 6870665346359048690}
|
||||||
|
m_RootOrder: 1
|
||||||
|
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: 0, y: 0}
|
||||||
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!222 &6870665345490481995
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6870665345490481988}
|
||||||
|
m_CullTransparentMesh: 1
|
||||||
|
--- !u!114 &6870665345490481994
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6870665345490481988}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, 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_FontData:
|
||||||
|
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
m_FontSize: 50
|
||||||
|
m_FontStyle: 0
|
||||||
|
m_BestFit: 0
|
||||||
|
m_MinSize: 5
|
||||||
|
m_MaxSize: 127
|
||||||
|
m_Alignment: 7
|
||||||
|
m_AlignByGeometry: 0
|
||||||
|
m_RichText: 1
|
||||||
|
m_HorizontalOverflow: 0
|
||||||
|
m_VerticalOverflow: 0
|
||||||
|
m_LineSpacing: 1
|
||||||
|
m_Text: New Text
|
||||||
|
--- !u!1 &6870665346359048685
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 6870665346359048690}
|
||||||
|
- component: {fileID: 6870665346359048691}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: loadingPanel
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &6870665346359048690
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6870665346359048685}
|
||||||
|
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: 6870665346376107586}
|
||||||
|
- {fileID: 6870665345490481989}
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 0
|
||||||
|
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: 0, y: 0}
|
||||||
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!114 &6870665346359048691
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6870665346359048685}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 93d59193d3d19fd42b350d0b7c2e29b5, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
targetText: {fileID: 6870665345490481994}
|
||||||
|
fullText: "\u6B63\u5728\u52A0\u8F7D\uFF0C\u8BF7\u7A0D\u5019..."
|
||||||
|
typewriterDelay: 0.1
|
||||||
|
SceneIndex: 0
|
||||||
|
--- !u!1 &6870665346376107645
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 6870665346376107586}
|
||||||
|
- component: {fileID: 6870665346376107584}
|
||||||
|
- component: {fileID: 6870665346376107587}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: bg
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &6870665346376107586
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6870665346376107645}
|
||||||
|
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: 6870665346359048690}
|
||||||
|
m_RootOrder: 0
|
||||||
|
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: 0, y: 0}
|
||||||
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!222 &6870665346376107584
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6870665346376107645}
|
||||||
|
m_CullTransparentMesh: 1
|
||||||
|
--- !u!114 &6870665346376107587
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6870665346376107645}
|
||||||
|
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, g: 0, b: 0, 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
|
7
meng_yao/Assets/Prefabs/ui/load/loadingPanel.prefab.meta
Normal file
7
meng_yao/Assets/Prefabs/ui/load/loadingPanel.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6839835fa4bd9ee4082efffc9eccc703
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -3170,6 +3170,8 @@ MonoBehaviour:
|
|||||||
scaleUpDuration: 0.4
|
scaleUpDuration: 0.4
|
||||||
tiaoScene: {fileID: 8646173536183414967}
|
tiaoScene: {fileID: 8646173536183414967}
|
||||||
Btns: []
|
Btns: []
|
||||||
|
_staminaBar: {fileID: 0}
|
||||||
|
loadPanelPrefab: {fileID: 6870665346359048685, guid: 6839835fa4bd9ee4082efffc9eccc703, type: 3}
|
||||||
--- !u!1 &8646173536251712116
|
--- !u!1 &8646173536251712116
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -35,7 +35,9 @@ public class Battle_Selection : BaseUI
|
|||||||
|
|
||||||
public List<Button> Btns;
|
public List<Button> Btns;
|
||||||
|
|
||||||
public StaminaBar _staminaBar;
|
public StaminaBar _staminaBar;
|
||||||
|
|
||||||
|
public GameObject loadPanelPrefab;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
async void Start()
|
async void Start()
|
||||||
@ -78,7 +80,8 @@ public class Battle_Selection : BaseUI
|
|||||||
|
|
||||||
_staminaBar.NumberInt -= 5;
|
_staminaBar.NumberInt -= 5;
|
||||||
|
|
||||||
SceneManager.LoadScene(2);
|
GameObject.Instantiate(loadPanelPrefab, GameObject.Find("myCanvas").transform).GetComponent<loadingPanel>().SceneIndex =
|
||||||
|
2;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
65
meng_yao/Assets/script/loadingPanel.cs
Normal file
65
meng_yao/Assets/script/loadingPanel.cs
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DG.Tweening;
|
||||||
|
using TMPro;
|
||||||
|
using System.Collections;
|
||||||
|
using Unity.VisualScripting;
|
||||||
|
|
||||||
|
public class loadingPanel : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Text targetText; // 需要显示动画的Text组件
|
||||||
|
public string fullText = "正在加载,请稍候..."; // 要显示的完整文本
|
||||||
|
public float typewriterDelay = 0.1f; // 打字机效果的间隔时间
|
||||||
|
public int SceneIndex;
|
||||||
|
|
||||||
|
// 控制加载场景和动画之间的时间同步
|
||||||
|
async void Start()
|
||||||
|
{
|
||||||
|
// 调用加载场景和显示动画的方法
|
||||||
|
await LoadSceneWithTextAnimation(SceneIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task LoadSceneWithTextAnimation(int sceneBuildIndex)
|
||||||
|
{
|
||||||
|
// 启动文本动画任务
|
||||||
|
Task textAnimationTask = AnimateText();
|
||||||
|
|
||||||
|
// 异步加载场景
|
||||||
|
AsyncOperation asyncOperation = SceneManager.LoadSceneAsync(sceneBuildIndex);
|
||||||
|
asyncOperation.allowSceneActivation = false; // 不自动激活场景
|
||||||
|
|
||||||
|
while (!asyncOperation.isDone)
|
||||||
|
{
|
||||||
|
// 根据加载进度更新UI
|
||||||
|
float progress = asyncOperation.progress;
|
||||||
|
|
||||||
|
// 更新文本内容,显示加载进度
|
||||||
|
targetText.text = $"{fullText} ({progress * 100:F0}%)";
|
||||||
|
|
||||||
|
// 当加载进度接近90%时,允许场景激活
|
||||||
|
if (progress >= 0.9f)
|
||||||
|
{
|
||||||
|
asyncOperation.allowSceneActivation = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 每帧执行一次任务,让文本动画继续进行
|
||||||
|
await Task.Yield();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 等待文本动画结束(如果它还没有结束)
|
||||||
|
await textAnimationTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行逐字显示文本动画
|
||||||
|
private async Task AnimateText()
|
||||||
|
{
|
||||||
|
// 逐字显示文本
|
||||||
|
for (int i = 0; i < fullText.Length; i++)
|
||||||
|
{
|
||||||
|
targetText.text = fullText.Substring(0, i + 1); // 逐个字符地拼接显示文本
|
||||||
|
await Task.Delay((int)(typewriterDelay * 1000)); // 控制显示的速度
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
meng_yao/Assets/script/loadingPanel.cs.meta
Normal file
11
meng_yao/Assets/script/loadingPanel.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 93d59193d3d19fd42b350d0b7c2e29b5
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user