title: Can an Android (Java not C/C++) plugin alter unity textures?
body: <p>I'm trying to use an Android plugin to get around the fact that Unity does not support Video Textures on mobile. I do this by getting the texture ID of the texture that will be used for video (supplied by <code>Texture2D.GetNativeTextureID()</code>) which i then pass into the Java Plugin.</p>
  
  <p>The plugin then follows a standard MediaPlayer implementation to play the video into a Surface Texture, which has been assigned the aforementioned texture ID.</p>
  
  <p>When i call the <code>MediaPlayer.Start()</code> method, LogCat outputs as if the media player is working normally/as hoped, however the texture never changes in the app. I'm calling the plugin (and even initializing it) from the <code>OnPreRender()</code> method of a monobehaviour script, along with making sure to call <code>GL.InvalidateState()</code> too.</p>
  
  <p>Here's a look at the relevant code:</p>
  
  <p>Constructor:</p>
  
  <pre><code>public VideoPlayer(String _path, Context _cont) {
      m_MediaPlayer = new MediaPlayer();
      try {
          Uri uri = Uri.parse(_path);
          m_MediaPlayer.setDataSource(_cont, uri);
          m_MediaPlayer.setOnPreparedListener(this);
      }
      catch (IOException e) {
          Log.e(TAG, "Error setting data source: " + e.getMessage());
      }
  }
  </code></pre>
  
  <p>Surface Texture Prep:</p>
  
  <pre><code>public void PrepareVideo(int _texPtr) {
      try {
          m_SurfTex = new SurfaceTexture(_texPtr);
          m_SurfTex.setOnFrameAvailableListener(this);
          Log.i(TAG, "Surface Texture ready");
          Surface surface = new Surface(m_SurfTex);
          m_MediaPlayer.setSurface(surface);
          Log.i(TAG, "Surface Ready");
          surface.release();
          m_Ready = true;
          m_MediaPlayer.prepare();
      }
      catch (IOException | IllegalStateException e) {
          Log.e(TAG, "Error preparing player: " + e.getMessage());
          m_Ready = false;
      }
  }
  </code></pre>
  
  <p>I'd like to know if this type of process is possible with my current setup, or will have to look into writing something using the NDK instead? Specifically, can a surface texture alter a texture produced in Unity?</p>