Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Ender1618 · May 30, 2012 at 08:44 PM · pluginsopenglsetpixels32

Updating a texture from a plugin for Unity 3.5 and later

I am attempting to update a Unity texture from a native plugin (I'm on Win7).

Prior to Unity 3.5 there were 2 ways of going about this. Utilizing SetPixels32 or forcing Unity to run in OpenGL mode and passing the GL texture ID down to the native code and using OpenGL to do a texture fill. The OpenGL method had some faults due to the fact that forcing OpenGL mode on Windows was kinda unsupported and might yield problems (which in my experiments it did).

In 3.5 and later, I have come to understand that rendering can happen on a different thread than the one the plugin functions are invoked on. So this makes updating the texture OpenGL style problematic. Does this also effect SetPixels32?

What is now the most efficient way to update a texture from a plugin on Windows 7 with Unity3.5.1? I saw that access to the dx device pointer is now possible, but I still run into the rendering thread not necessarily being the same as the plugin thread. I heard there is some kind of callback mechanism, but I am having trouble finding out how to use it for doing plugin texture updates.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by simonmc · May 30, 2012 at 08:58 PM

What you say is correct, however using the supplied callbacks is very easy, and the documentation can be found here:

[http://unity3d.com/support/documentation/Manual/NativePluginInterface.html][1]

This page contains information about how it works, as well as an example project showing how to call both OpenGL and Direct3D code on the rendering thread.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by mruce · Jul 23, 2012 at 07:15 PM

Hi, I've got same problem here - I'm trying to find a fast way to update texture in Unity. I've got no expierience with DX (came from XNA) - have you managed to use a native plugin?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by davegirdy · Feb 27, 2013 at 10:44 PM

I am having problems understanding how to use Direct3d as well. It seems that to matter how I initialize my Texture2d in unity, the size of the D3DSURFACE_DESC is always 1024x512 in the rendering plugin. This is making my rendering code very difficult. Is there way to set different dimensions?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

glReadPixels in native plugin shows different results for different Unity versions 1 Answer

plugins folder & .dll 0 Answers

Use .net 4.0 unsupported mono libraries via plugins 0 Answers

Handle sound inside native unity iOS plugin 0 Answers

Xamarin Android Plugins for Unity 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges