添加了3DText
This commit is contained in:
8
Assets/Scripts/HotUpdate/Main/Dialogue.meta
Normal file
8
Assets/Scripts/HotUpdate/Main/Dialogue.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 96de0f25ee17bf54ab70a62329b464e5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
46
Assets/Scripts/HotUpdate/Main/Dialogue/Dialogue.cs
Normal file
46
Assets/Scripts/HotUpdate/Main/Dialogue/Dialogue.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Dialogue : MonoBehaviour
|
||||
{
|
||||
public DialogueData curData;
|
||||
public MyTypewriter typewriter;
|
||||
public AudioSource textAudio;
|
||||
private void Awake()
|
||||
{
|
||||
if(typewriter==null)
|
||||
typewriter = GetComponent<MyTypewriter>();
|
||||
}
|
||||
public void SetData(DialogueData _curData)
|
||||
{
|
||||
curData = _curData;
|
||||
typewriter.text = curData.dialogueText;
|
||||
|
||||
}
|
||||
public void Play()
|
||||
{
|
||||
SetTransform();
|
||||
StartTypewriter();
|
||||
PlayAudio();
|
||||
}
|
||||
public void SetTransform()
|
||||
{
|
||||
gameObject.transform.position = curData.worldPosition;
|
||||
gameObject.transform.eulerAngles = curData.rotataion;
|
||||
gameObject.transform.localScale = curData.scale;
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
public void StartTypewriter()
|
||||
{
|
||||
typewriter.StartTyping();
|
||||
}
|
||||
public void PlayAudio()
|
||||
{
|
||||
if (textAudio != null)
|
||||
{
|
||||
textAudio.clip = curData.voiceOver;
|
||||
textAudio.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/HotUpdate/Main/Dialogue/Dialogue.cs.meta
Normal file
11
Assets/Scripts/HotUpdate/Main/Dialogue/Dialogue.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13dc8ba147ad9aa42ad95fcd6ee6d934
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
43
Assets/Scripts/HotUpdate/Main/Dialogue/DialogueDatabase.cs
Normal file
43
Assets/Scripts/HotUpdate/Main/Dialogue/DialogueDatabase.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
[CreateAssetMenu(fileName = "NewDialogueDatabase", menuName = "Dialogue/Dialogue Database")]
|
||||
public class DialogueDatabase : ScriptableObject
|
||||
{
|
||||
public List<DialogueData> dialogues = new List<DialogueData>();
|
||||
public DialogueData GetDialogueById(int id)
|
||||
{
|
||||
return dialogues.Find(d => d.id == id);
|
||||
}
|
||||
public bool TryGetDialogue(int id,out DialogueData dialogue)
|
||||
{
|
||||
dialogue = dialogues.Find(d => d.id == id);
|
||||
return dialogue != null;
|
||||
}
|
||||
}
|
||||
[System.Serializable]
|
||||
public class DialogueData
|
||||
{
|
||||
public int id;
|
||||
public string speakerName;
|
||||
public string dialogueText;
|
||||
public AudioClip voiceOver;
|
||||
public float displayDuration = 5f;
|
||||
public Vector3 worldPosition;
|
||||
public Vector3 rotataion;
|
||||
public Vector3 scale = Vector3.one;
|
||||
public int nextDialogueId = -1;
|
||||
|
||||
public UnityEvent onStart;
|
||||
public UnityEvent onEnd;
|
||||
public List<DialogueEvent> dialogueEvents;
|
||||
}
|
||||
[Serializable]
|
||||
public class DialogueEvent
|
||||
{
|
||||
public float triggerTime;
|
||||
public UnityEvent onTrigger;
|
||||
public bool hasTriggered;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9fd9ee25f5678b34daeacdaf6c854a9e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
183
Assets/Scripts/HotUpdate/Main/Dialogue/DialogueManager.cs
Normal file
183
Assets/Scripts/HotUpdate/Main/Dialogue/DialogueManager.cs
Normal file
@@ -0,0 +1,183 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Mirror;
|
||||
using YooAsset;
|
||||
|
||||
/*
|
||||
Documentation: https://mirror-networking.gitbook.io/docs/guides/networkbehaviour
|
||||
API Reference: https://mirror-networking.com/docs/api/Mirror.NetworkBehaviour.html
|
||||
*/
|
||||
|
||||
public class DialogueManager : NetworkBehaviour
|
||||
{
|
||||
public static DialogueManager Inst;
|
||||
|
||||
public DialogueDatabase dialogueDatabase;
|
||||
public GameObject dialoguePrefab;
|
||||
public Dialogue curDialogue;
|
||||
|
||||
[SyncVar(hook = nameof(OnCurrentDialogueChanged))]
|
||||
int currentDialogueId = -1;
|
||||
Dictionary<int, DialogueData> dialogueMap = new Dictionary<int, DialogueData>();
|
||||
void OnCurrentDialogueChanged(int oldId,int newId)
|
||||
{
|
||||
if(newId == -1)
|
||||
{
|
||||
Destroy(curDialogue.gameObject);
|
||||
curDialogue = null;
|
||||
}
|
||||
else if(dialogueMap.ContainsKey(currentDialogueId))
|
||||
{
|
||||
PlayDialogue(currentDialogueId);
|
||||
}
|
||||
}
|
||||
public void PlayDialogue(int id)
|
||||
{
|
||||
if (curDialogue)
|
||||
{
|
||||
curDialogue.SetData(dialogueMap[id]);
|
||||
curDialogue.Play();
|
||||
}
|
||||
}
|
||||
public void HideDialogue()
|
||||
{
|
||||
if (curDialogue)
|
||||
curDialogue.gameObject.SetActive(false);
|
||||
}
|
||||
[Server]
|
||||
public void StartDialogue(int id)
|
||||
{
|
||||
if (dialogueMap.ContainsKey(id))
|
||||
{
|
||||
currentDialogueId = id; // 修改 SyncVar,自动同步到所有客户端
|
||||
}
|
||||
}
|
||||
|
||||
[Server]
|
||||
public void EndCurrentDialogue()
|
||||
{
|
||||
if (currentDialogueId != -1)
|
||||
{
|
||||
currentDialogueId = -1; // 修改 SyncVar,所有客户端自动关闭
|
||||
}
|
||||
}
|
||||
|
||||
#region Unity Callbacks
|
||||
|
||||
/// <summary>
|
||||
/// Add your validation code here after the base.OnValidate(); call.
|
||||
/// </summary>
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
}
|
||||
|
||||
// NOTE: Do not put objects in DontDestroyOnLoad (DDOL) in Awake. You can do that in Start instead.
|
||||
void Awake()
|
||||
{
|
||||
if (Inst == null)
|
||||
Inst = this;
|
||||
LoadDialogueDatabase();
|
||||
LoadDialoguePrefab();
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
}
|
||||
|
||||
void LoadDialogueDatabase()
|
||||
{
|
||||
|
||||
if (dialogueDatabase == null)
|
||||
{
|
||||
YooAssets.LoadAssetAsync<DialogueDatabase>("DialogueDatabase").Completed += (handle) =>
|
||||
{
|
||||
dialogueDatabase = handle.AssetObject as DialogueDatabase;
|
||||
dialogueMap = new Dictionary<int, DialogueData>();
|
||||
foreach (DialogueData dialogue in dialogueDatabase.dialogues)
|
||||
{
|
||||
if (dialogue != null && !dialogueMap.ContainsKey(dialogue.id))
|
||||
{
|
||||
dialogueMap[dialogue.id] = dialogue;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
void LoadDialoguePrefab()
|
||||
{
|
||||
if (dialoguePrefab == null)
|
||||
{
|
||||
YooAssets.LoadAssetAsync<GameObject>("MyTypewriter").Completed += (handle) =>
|
||||
{
|
||||
dialoguePrefab = handle.AssetObject as GameObject;
|
||||
CreateDialogue();
|
||||
};
|
||||
}
|
||||
}
|
||||
void CreateDialogue()
|
||||
{
|
||||
if (curDialogue == null)
|
||||
{
|
||||
curDialogue = Instantiate(dialoguePrefab).GetComponent<Dialogue>();
|
||||
curDialogue.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Start & Stop Callbacks
|
||||
|
||||
/// <summary>
|
||||
/// This is invoked for NetworkBehaviour objects when they become active on the server.
|
||||
/// <para>This could be triggered by NetworkServer.Listen() for objects in the scene, or by NetworkServer.Spawn() for objects that are dynamically created.</para>
|
||||
/// <para>This will be called for objects on a "host" as well as for object on a dedicated server.</para>
|
||||
/// </summary>
|
||||
public override void OnStartServer() { }
|
||||
|
||||
/// <summary>
|
||||
/// Invoked on the server when the object is unspawned
|
||||
/// <para>Useful for saving object data in persistent storage</para>
|
||||
/// </summary>
|
||||
public override void OnStopServer() { }
|
||||
|
||||
/// <summary>
|
||||
/// Called on every NetworkBehaviour when it is activated on a client.
|
||||
/// <para>Objects on the host have this function called, as there is a local client on the host. The values of SyncVars on object are guaranteed to be initialized correctly with the latest state from the server when this function is called on the client.</para>
|
||||
/// </summary>
|
||||
public override void OnStartClient() { }
|
||||
|
||||
/// <summary>
|
||||
/// This is invoked on clients when the server has caused this object to be destroyed.
|
||||
/// <para>This can be used as a hook to invoke effects or do client specific cleanup.</para>
|
||||
/// </summary>
|
||||
public override void OnStopClient() { }
|
||||
|
||||
/// <summary>
|
||||
/// Called when the local player object has been set up.
|
||||
/// <para>This happens after OnStartClient(), as it is triggered by an ownership message from the server. This is an appropriate place to activate components or functionality that should only be active for the local player, such as cameras and input.</para>
|
||||
/// </summary>
|
||||
public override void OnStartLocalPlayer() { }
|
||||
|
||||
/// <summary>
|
||||
/// Called when the local player object is being stopped.
|
||||
/// <para>This happens before OnStopClient(), as it may be triggered by an ownership message from the server, or because the player object is being destroyed. This is an appropriate place to deactivate components or functionality that should only be active for the local player, such as cameras and input.</para>
|
||||
/// </summary>
|
||||
public override void OnStopLocalPlayer() {}
|
||||
|
||||
/// <summary>
|
||||
/// This is invoked on behaviours that have authority, based on context and <see cref="NetworkIdentity.hasAuthority">NetworkIdentity.hasAuthority</see>.
|
||||
/// <para>This is called after <see cref="OnStartServer">OnStartServer</see> and before <see cref="OnStartClient">OnStartClient.</see></para>
|
||||
/// <para>When <see cref="NetworkIdentity.AssignClientAuthority">AssignClientAuthority</see> is called on the server, this will be called on the client that owns the object. When an object is spawned with <see cref="NetworkServer.Spawn">NetworkServer.Spawn</see> with a NetworkConnectionToClient parameter included, this will be called on the client that owns the object.</para>
|
||||
/// </summary>
|
||||
public override void OnStartAuthority() { }
|
||||
|
||||
/// <summary>
|
||||
/// This is invoked on behaviours when authority is removed.
|
||||
/// <para>When NetworkIdentity.RemoveClientAuthority is called on the server, this will be called on the client that owns the object.</para>
|
||||
/// </summary>
|
||||
public override void OnStopAuthority() { }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 99f197364a790c248a68f93a85ca61c0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
22
Assets/Scripts/HotUpdate/Main/Dialogue/FallingObj.cs
Normal file
22
Assets/Scripts/HotUpdate/Main/Dialogue/FallingObj.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class FallingObj : MonoBehaviour
|
||||
{
|
||||
public float delay;
|
||||
public Vector3 force;
|
||||
public void Init(float delay, Vector3 force)
|
||||
{
|
||||
this.delay = delay;
|
||||
this.force = force;
|
||||
StartCoroutine(Falling());
|
||||
}
|
||||
IEnumerator Falling()
|
||||
{
|
||||
yield return new WaitForSeconds(delay);
|
||||
gameObject.AddComponent<MeshCollider>().convex = true;
|
||||
//gameObject.AddComponent<Rigidbody>().useGravity = false;
|
||||
gameObject.AddComponent<Rigidbody>().AddForce(force,ForceMode.Impulse);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/HotUpdate/Main/Dialogue/FallingObj.cs.meta
Normal file
11
Assets/Scripts/HotUpdate/Main/Dialogue/FallingObj.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0ff2d93a504d8748a9d03c60ff7879a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
112
Assets/Scripts/HotUpdate/Main/Dialogue/MyTypewriter.cs
Normal file
112
Assets/Scripts/HotUpdate/Main/Dialogue/MyTypewriter.cs
Normal file
@@ -0,0 +1,112 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TinyGiantStudio.Layout;
|
||||
using TinyGiantStudio.Text;
|
||||
using UnityEngine;
|
||||
|
||||
public class MyTypewriter : MonoBehaviour
|
||||
{
|
||||
[TextArea]
|
||||
public string text = "Typewriter text";
|
||||
[Space(20)]
|
||||
|
||||
public Modular3DText modular3DText = null;
|
||||
[SerializeField] bool startAutomatically = true;
|
||||
[SerializeField] float startDelay = 1;
|
||||
[Tooltip("Minimum and maximum possible speed.")]
|
||||
public Vector2 typeDelay = new Vector2(0.01f, 0.1f);
|
||||
[SerializeField] string typingSymbol = null;
|
||||
|
||||
|
||||
[Space(10)]
|
||||
[SerializeField] AudioClip typeSound = null;
|
||||
[Tooltip("Minimum and maximum possible volume. \nA variation of values makes it look natural.")]
|
||||
[SerializeField] Vector2 volume = Vector2.one;
|
||||
[SerializeField] AudioSource audioSource = null;
|
||||
|
||||
public float fallingDelay;
|
||||
public Vector3 fallingForce;
|
||||
|
||||
///If disabled while typing, this lets the script know it should start the routine again
|
||||
private bool typing = false;
|
||||
///If typewriter is resumed, the effect resumes from this number letter.
|
||||
private int currentLetter;
|
||||
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if (startAutomatically & modular3DText)
|
||||
modular3DText.Text = string.Empty;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (startAutomatically)
|
||||
StartTyping();
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
if (typing)
|
||||
{
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(TypingRoutine());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// If gameobject is enabled, this starts a coroutine for the typewriter
|
||||
/// </summary>
|
||||
public void StartTyping()
|
||||
{
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(FirstStart());
|
||||
typing = true;
|
||||
}
|
||||
|
||||
IEnumerator FirstStart()
|
||||
{
|
||||
yield return null;
|
||||
yield return new WaitForSeconds(startDelay);
|
||||
StartCoroutine(TypingRoutine());
|
||||
}
|
||||
|
||||
IEnumerator TypingRoutine()
|
||||
{
|
||||
if (modular3DText)
|
||||
{
|
||||
for (int i = currentLetter; i <= text.Length; i++)
|
||||
{
|
||||
modular3DText.Text = (text.Substring(0, i) + typingSymbol);
|
||||
|
||||
|
||||
yield return null;
|
||||
yield return new WaitForSeconds(Random.Range(typeDelay.x, typeDelay.y));
|
||||
|
||||
if (audioSource && typeSound)
|
||||
{
|
||||
audioSource.pitch = Random.Range(0.9f, 1.1f);
|
||||
audioSource.PlayOneShot(typeSound, Random.Range(volume.x, volume.y));
|
||||
}
|
||||
currentLetter = i;
|
||||
}
|
||||
typing = false;
|
||||
StartCoroutine(TextFalling());
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("<color=red>No text object is selected on typewriter.</color> :" + gameObject.name, gameObject);
|
||||
}
|
||||
}
|
||||
IEnumerator TextFalling()
|
||||
{
|
||||
foreach (GameObject child in modular3DText.characterObjectList)
|
||||
{
|
||||
float delay = Random.Range(0, fallingDelay);
|
||||
Vector3 force = new Vector3(Random.Range(0, fallingForce.x), Random.Range(0, fallingForce.y), Random.Range(0, fallingForce.z));
|
||||
child.AddComponent<FallingObj>().Init(delay, force);
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/HotUpdate/Main/Dialogue/MyTypewriter.cs.meta
Normal file
11
Assets/Scripts/HotUpdate/Main/Dialogue/MyTypewriter.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25e56d79041ca8f4190c288e08a5ae8b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -5,7 +5,6 @@ using YooAsset;
|
||||
|
||||
public class GameStart : MonoBehaviour
|
||||
{
|
||||
SceneHandle sceneHandle;
|
||||
|
||||
void Start()
|
||||
{
|
||||
@@ -33,10 +32,15 @@ public class GameStart : MonoBehaviour
|
||||
}
|
||||
IEnumerator LoadMainScene()
|
||||
{
|
||||
sceneHandle = YooAssets.LoadSceneAsync("MirrorRoomOffline");
|
||||
//sceneHandle = YooAssets.LoadSceneAsync("Game");
|
||||
SceneHandle sceneHandle = YooAssets.LoadSceneAsync("MirrorRoomOffline");
|
||||
UIManager.Inst.ShowWindow<LoadingWindow>("LoadingWindow", window =>
|
||||
{
|
||||
window.TrackOperation(sceneHandle);
|
||||
sceneHandle.UnSuspend();
|
||||
});
|
||||
sceneHandle.Completed += (handle) =>
|
||||
{
|
||||
GameManager.Inst.MainUICanvas.transform.Find("PatchWindow").gameObject.SetActive(false);
|
||||
handle.ActivateScene();
|
||||
StartCoroutine(LoadNetWorkHUD());
|
||||
};
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
"GUID:8804cd4b3fef1e041ad4f6c94ec49e0c",
|
||||
"GUID:30817c1a0e6d646d99c048fc403f5979",
|
||||
"GUID:72872094b21c16e48b631b2224833d49",
|
||||
"GUID:3a5d3214f3d7fb845bf8991981763e58"
|
||||
"GUID:3a5d3214f3d7fb845bf8991981763e58",
|
||||
"GUID:5c6fbff432f72be408d8eebe98b69878"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Mirror;
|
||||
using Mirror.Discovery;
|
||||
|
||||
public class MyNetworkManagerHUD : MonoBehaviour
|
||||
{
|
||||
@@ -21,6 +22,13 @@ public class MyNetworkManagerHUD : MonoBehaviour
|
||||
[SerializeField] private InputField inputNetworkAddress;
|
||||
[SerializeField] private InputField inputPort;
|
||||
|
||||
// this will check for games to join, if non, start host.
|
||||
public bool alwaysAutoStart = false;
|
||||
public NetworkDiscovery networkDiscovery;
|
||||
readonly Dictionary<long, ServerResponse> discoveredServers = new Dictionary<long, ServerResponse>();
|
||||
private TouchScreenKeyboard keyboard;
|
||||
private int keyboardStatus = 0;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// Init the input field with Network Manager's network address.
|
||||
@@ -32,6 +40,32 @@ public class MyNetworkManagerHUD : MonoBehaviour
|
||||
//RegisterClientEvents();
|
||||
|
||||
CheckWebGLPlayer();
|
||||
|
||||
if (networkDiscovery == null)
|
||||
{ networkDiscovery = GameObject.FindObjectOfType<NetworkDiscovery>(); }
|
||||
|
||||
if (alwaysAutoStart)
|
||||
{
|
||||
StartCoroutine(Waiter());
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator Waiter()
|
||||
{
|
||||
statusText.text = "Discovering servers..";
|
||||
discoveredServers.Clear();
|
||||
networkDiscovery.StartDiscovery();
|
||||
// we have set this as 3.1 seconds, default discovery scan is 3 seconds, allows some time if host and client are started at same time
|
||||
yield return new WaitForSeconds(1.1f);
|
||||
if (discoveredServers == null || discoveredServers.Count <= 0)
|
||||
{
|
||||
statusText.text = "No Servers found, starting as Host.";
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
discoveredServers.Clear();
|
||||
// NetworkManager.singleton.onlineScene = SceneManager.GetActiveScene().name;
|
||||
MyRoomManager.singleton.StartHost();
|
||||
networkDiscovery.AdvertiseServer();
|
||||
}
|
||||
}
|
||||
|
||||
private void RegisterListeners()
|
||||
|
||||
8
Assets/Scripts/HotUpdate/Main/UI/LoadingWindow.meta
Normal file
8
Assets/Scripts/HotUpdate/Main/UI/LoadingWindow.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b273eeefab12b774ca0fffb36391a0db
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,37 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using YooAsset;
|
||||
|
||||
public class LoadingWindow : UIBaseWindow
|
||||
{
|
||||
public Slider slider;
|
||||
public Text progressText;
|
||||
private HandleBase _currentOperation;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (_currentOperation == null) return;
|
||||
|
||||
slider.value = _currentOperation.Progress;
|
||||
Debug.Log(slider.value);
|
||||
if (progressText != null)
|
||||
progressText.text = $"{_currentOperation.Progress * 100:F0}%";
|
||||
|
||||
if (_currentOperation.IsDone)
|
||||
StopTracking();
|
||||
}
|
||||
|
||||
public void TrackOperation(HandleBase operation)
|
||||
{
|
||||
_currentOperation = operation;
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void StopTracking()
|
||||
{
|
||||
_currentOperation = null;
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e49b2fed14fbfcd48804c019a87aee19
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -40,6 +40,6 @@ public class PatchWindow : MonoBehaviour
|
||||
{
|
||||
statusText.text = "更新失败";
|
||||
}
|
||||
gameObject.SetActive(false);
|
||||
//gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user