转跳到内容

dkymore

【会员】限制会员
  • 内容数

    3
  • 加入

  • 最后访问

关于dkymore

经济

  • 羽毛 0.00 根
  • 节操值 0.00 节操值

最近资料访问用户

180 次访问

dkymore的成就

史莱姆勇者【哪个勇者不是从史莱姆打起】

史莱姆勇者【哪个勇者不是从史莱姆打起】 (1/9)

  1. 把 现实认识的|游戏认识的|路人 分个组 这样就不乱了 如果不限制好友数 就没必要删 如果限制的话 就从路人下手吧
  2. 本萌新最近想用UNITY做个游戏 可是好难啊,,, 有没有大佬教教我异步 比如异步加载 和AutoResetEvent class Program { static void Main() { Request req = new Request(); //这个人去干三件大事 Thread GetCarThread = new Thread(new ThreadStart(req.InterfaceA)); GetCarThread.Start(); Thread GetHouseThead = new Thread(new ThreadStart(req.InterfaceB)); GetHouseThead.Start(); //等待三件事都干成的喜讯通知信息 AutoResetEvent.WaitAll(req.autoEvents); //这个人就开心了。 req.InterfaceC(); System.Console.ReadKey(); } } public class Request { //建立事件数组 public AutoResetEvent[] autoEvents = null; public Request() { autoEvents = new AutoResetEvent[] { new AutoResetEvent(false), new AutoResetEvent(false) }; } public void InterfaceA() { System.Console.WriteLine("请求A接口"); Thread.Sleep(1000*2); autoEvents[0].Set(); System.Console.WriteLine("A接口完成"); } public void InterfaceB() { System.Console.WriteLine("请求B接口"); Thread.Sleep(1000 * 1); autoEvents[1].Set(); System.Console.WriteLine("B接口完成"); } public void InterfaceC() { System.Console.WriteLine("两个接口都已经请求完,正在处理C"); } } public class AsyncLoadScene : MonoBehaviour { public Slider loadingSlider; public Text loadingText; private float loadingSpeed = 1; private float targetValue; private AsyncOperation operation; // Use this for initialization void Start () { loadingSlider.value = 0.0f; if (SceneManager.GetActiveScene().name == "Loading") { //启动协程 StartCoroutine(AsyncLoading()); } } IEnumerator AsyncLoading() { operation = SceneManager.LoadSceneAsync(Globe.nextSceneName); //阻止当加载完成自动切换 operation.allowSceneActivation = false; yield return operation; } // Update is called once per frame void Update () { targetValue = operation.progress; if (operation.progress >= 0.9f) { //operation.progress的值最大为0.9 targetValue = 1.0f; } if (targetValue != loadingSlider.value) { //插值运算 loadingSlider.value = Mathf.Lerp(loadingSlider.value, targetValue, Time.deltaTime * loadingSpeed); if (Mathf.Abs(loadingSlider.value - targetValue) < 0.01f) { loadingSlider.value = targetValue; } } loadingText.text = ((int)(loadingSlider.value * 100)).ToString() + "%"; if ((int)(loadingSlider.value * 100) == 100) { //允许异步加载完毕后自动切换场景 operation.allowSceneActivation = true; }
×
×
  • 新建...

重要消息

为使您更好地使用该站点,请仔细阅读以下内容: 使用条款