Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        AsyncTextureReader.InitDebugLogs();

        Pixels = new byte[DebugTexture.width * DebugTexture.height * 4];


        Debug.Log("Request Status: " + AsyncTextureReader.RequestTextureData(DebugTexture));
        Debug.Log("Retrieve Status: " + AsyncTextureReader.RetrieveTextureData(DebugTexture, Pixels));
    }
Exemplo n.º 2
0
    private void GetPixels()
    {
        if (Pixels == null)
        {
            return;
        }

        AsyncTextureReader.Status status = AsyncTextureReader.RetrieveTextureData(DebugTexture, Pixels);
        Debug.LogFormat("Frame: {0}; Retrieve Status: {1}", Time.frameCount, status);
        if (status == AsyncTextureReader.Status.Succeeded)
        {
            // print RGBA of first pixel
            Debug.LogFormat("Pixel RGBA: {0}; {1}; {2}; {3}", Pixels[0], Pixels[1], Pixels[2], Pixels[3]);
            Pixels = null;
        }
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (Pixels == null)
        {
            return;
        }

        AsyncTextureReader.Status status = AsyncTextureReader.RetrieveTextureData(DebugTexture, Pixels);
        Debug.Log("Retrieve Status: " + status);
        if (status == AsyncTextureReader.Status.Succeeded)
        {
            // print RGBA of first pixel
            Debug.LogFormat("Pixel RGBA: {0}; {1}; {2}; {3}", Pixels[0], Pixels[1], Pixels[2], Pixels[3]);
            Pixels = null;
        }
    }
Exemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        _buffer = new ComputeBuffer(4, sizeof(float));
        _buffer.SetData(new float[] { 1, 2, 3, 4 });

        AsyncTextureReader.InitDebugLogs();

        Pixels = new byte[DebugTexture.width * DebugTexture.height * 4];

        Debug.LogFormat("Frame: {0}; Request Status: {1}", Time.frameCount, AsyncTextureReader.RequestTextureData(DebugTexture));
        Debug.LogFormat("Frame: {0}; Retrieve Status: {1}", Time.frameCount, AsyncTextureReader.RetrieveTextureData(DebugTexture, Pixels));

#if UNITY_5_5_OR_NEWER
        AsyncTextureReader.RequestBufferData(_buffer);
#endif
    }