Hi - As a test I want to see if I can utilize System.Drawing objects from Unity. Here is what i've done... 1. Create a script which utilizes System.Drawing objects. 2. Copied System.Drawing.dll from the mono framework included with Unity into my projects Standard Assets folder. 3. When I run the code I get the error 'TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.GDIPlus. System.Drawing calls into the file libgdiplus.dylib. So i've included libgdiplus.dylib and all other libgdiplus files in my Standard Assets folder. I've also places these files into the Mono Framework folder included with Unity. Still same error. Anyone have any ideas? thanks -
I've attached what I would like to draw. This can be done pretty easily using the GraphicsPath class availabe in GDI+. I'm not sure how to do this in Unity. The image is used to display a chat bubble above my characters head. The size of the image is dynamic based on the size of the text in the image. The text can be almost anything although it will not be larger then N characters where N is still being defined. The image is basically four arcs and 4 lines. Thanks -
The problem is that none of "standard drawing libraries" (System.Drawing, ...) will integrate well with actual game drawing that is done via OpenGL/Direct3D. What you should do, I think: use regular Unity GUI. Make a style for your text bubble with this background, and set up it's borders so that bubble shape is correct no matter what's the size.
What I planned on doing was create the bitmap using System.Drawing, then save the bitmap to a memory stream. Once in a memory stream I would convert to a byte array which I would load into a texture, using texture.LoadImage. I didn't plan on using the System.Drawing stuff to draw directly into Unity. Does this make sense? I understand what you are saying to make a style with this background, but how would I setup the bubble shape's borders so it is correct no matter what the size? I would rather do what your suggesting if I can understand it better. Keeping it all in Unity will be easier to maintain! Thanks -
Download the Networking example project. Run it and type something into the chat window. The chat messages are contained within a speech bubble using this technique.
Thanks for the networking tutorial! The chat is exactly what I want visually. I've actually got it working in my project. The problem is I want the chat bubble to be billboarded so it always faces the camera. Plus I want the chat bubble to slowly fade away after a specified interval. I'm not sure I can do this using the GUILayout which is used in the tutorial. I will keep plugging away using the chat bubble from the tutorial to see what I can get. Thanks again for the help!
Anything done with OnGUI is only 2D, so you don't have a choice--it will always face the camera no matter what. You can use GUI.color.a to fade things out. --Eric
Can I use System.Drawing library in Unity now? I want to manipulate my contrast script faster than the way that Unity does it pixel by pixel. I want to use a ColorMatrix or LockBits to adjust contrast/brightness of my image faster.
Still have problem. Wonder if anybody could help me! I can copy System.Drawing.dll to asset to do something with Bitmap. Works perfectly on Editor, but fail on build!