歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Android+Unity游戲開發之C#線程

Android+Unity游戲開發之C#線程

日期:2017/3/1 10:56:34   编辑:Linux編程

以前我們都是用javascript開發unity的,但是我今天才發現個問題,那就是javascript裡面沒有線程。沒辦法我只能用C#了,其實C#和java才不多的,有我們的線程,下面我就舉個簡單的例子來說明一下吧;

  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Threading;
  4. public class move1: MonoBehaviour {
  5. void Start () {
  6. MyThread mt = new MyThread("thread");
  7. Thread newnewThrd = new Thread(new ThreadStart(mt.run));
  8. newThrd.Start();
  9. }
  10. void Update(){}
  11. }
  12. public class MyThread
  13. {
  14. public int count;
  15. string thrdName;
  16. public MyThread(string nam)
  17. {
  18. count = 0;
  19. thrdName = nam;
  20. }
  21. public void run()
  22. {
  23. Debug.Log(thrdName);
  24. }
  25. }

我也不說多的了,C#我也還沒學過,還好學過了java了,大家一定要記得加using system.Threading哦~~~。

Copyright © Linux教程網 All Rights Reserved