Exemple #1
0
        /// <inheritdoc />
        protected override void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            foreach (var rtv in RtvArraySlices)
            {
                rtv.Dispose();
            }
            foreach (var srv in SrvArraySlices)
            {
                srv.Dispose();
            }
            foreach (var dsv in DsvArraySlices)
            {
                dsv.Dispose();
            }

            NativeTexture?.Dispose();

            RtvArraySlices.Clear();
            SrvArraySlices.Clear();
            DsvArraySlices.Clear();

            _disposed = true;
        }
Exemple #2
0
 protected override void DisposeData()
 {
     if (NativeResourceView != null)
     {
         NativeResourceView.Dispose();
     }
     if (NativeTexture != null)
     {
         NativeTexture.Dispose();
     }
 }
Exemple #3
0
    void OnGUI()
    {
        if (GUILayout.Button("TakeSnap", GUILayout.Height(150), GUILayout.Width(150)))
        {
            Debug.Log("TakeSnap " + imgpath);
            TakeScreenShotFromScreenSize(tex =>
            {
                SaveTexture(tex, imgpath);
            });
        }

        if (GUILayout.Button("LoadByCS", GUILayout.Height(150), GUILayout.Width(150)))
        {
            Debug.Log("Load By CS " + imgpath);
            if (!File.Exists(imgpath))
            {
                Debug.LogError(imgpath + " not exist!!!");
            }
            var       bytes   = File.ReadAllBytes(imgpath);
            Texture2D texture = new Texture2D(1280, 800);
            texture.LoadImage(bytes);
            img.texture = texture;
        }

        if (GUILayout.Button("Load", GUILayout.Height(150), GUILayout.Width(150)))
        {
            Debug.Log("Load " + imgpath);
            if (!File.Exists(imgpath))
            {
                Debug.LogError(imgpath + " not exist!!!");
            }
            currentRawTexture = new NativeTexture(imgpath);
            img.texture       = currentRawTexture.Tex;
        }

        if (GUILayout.Button("LoadFromStreamingAssets", GUILayout.Height(150), GUILayout.Width(150)))
        {
            Debug.Log("LoadFromStreamingAssets " + "test.png");
            currentRawTexture = new NativeTexture("test.png", true);
            img.texture       = currentRawTexture.Tex;
        }

        if (GUILayout.Button("UnLoad", GUILayout.Height(150), GUILayout.Width(150)))
        {
            Debug.Log("UnLoad");
            currentRawTexture.Dispose();
        }
    }