Beispiel #1
0
    public static TextureInfoOtherThread GetTextureInfoOtherThread(
        string name, string path, Action <TextureInfo> callback)
    {
        var ti = new TextureInfoOtherThread
        {
            name     = name,
            path     = path,
            callback = callback,
            mutex    = null,
        };

        texture_other_threads.Add(ti);
        return(ti);
    }
Beispiel #2
0
    static IEnumerator UpdateRenderOP()
    {
        while (true)
        {
            do
            {
                yield return(new WaitForSeconds(15));
            } while(texture_other_threads.Count == 0 &&
                    render_texture_other_threads.Count == 0);

            TextureInfo ti = null;
            if (texture_other_threads.Count > 0)
            {
                TextureInfoOtherThread tiot = null;
                var tiotiter = texture_other_threads.GetEnumerator();
                while (tiotiter.MoveNext())
                {
                    tiot       = tiotiter.Current;
                    tiot.mutex = new System.Threading.Mutex(true);
                    //tiot.mutex.WaitOne();
                    ti = GetTextureInfo(tiot.name, tiot.path);
                    tiot.callback(ti);
                    tiot.mutex.ReleaseMutex();
                }
                texture_other_threads.Clear();
            }
            if (render_texture_other_threads.Count > 0)
            {
                RenderTextureOtherThread rtot = null;
                var rtotiter = render_texture_other_threads.GetEnumerator();
                while (rtotiter.MoveNext())
                {
                    rtot       = rtotiter.Current;
                    rtot.mutex = new System.Threading.Mutex(true);
                    //tiot.mutex.WaitOne();
                    var rt = new RenderTexture(rtot.x, rtot.y, 24, RenderTextureFormat.ARGB32);
                    rtot.callback(rt);
                    rtot.mutex.ReleaseMutex();
                }
                render_texture_other_threads.Clear();
            }
        }
    }