How to use C # streams in unity 3D for Android platform?

I need to upload files, scenes and play animations in streams. Tried to upload files via www to Android ... how to do other things through streams? But why does the game engine not allow us to create threads? or is my understanding wrong? How to create threads in UNITY3D?

+4
source share
3 answers

You can use threads in Unity, but the mechanism is not thread safe. Usually, you start separate threads (from the Unity user interface) to perform lengthy processes and check the results (you cannot interact with Unity from a workflow). A general approach is to use a class that represents a thread job that will be initialized by the Unity main thread. Then you start the workflow on a function of this class and let it do the job (Coroutines run in the main Unity thread, so they are not real threads. The best article on Coroutines is here )

Here is an example of the approach described above (see accepted answer):

http://answers.unity3d.com/questions/357033/unity3d-and-c-coroutines-vs-threading.html

UnityGems, , (, ). .

. !

+5

Unity / , - Unity api. , , gameObject . , , . ! , .

+3

Unity3D Approach, Coroutines.

IEnumerator DoSth()
{
    ...
    yield retrun ... ;       
}

/ :

StartCoroutine(DoSth());  // OK
StartCoroutine("DoSth");  // Also fine
StopCoroutine("DoSth");   // You can stop it as well
0
source

Source: https://habr.com/ru/post/1529711/


All Articles