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 fherbst · Jan 26, 2011 at 12:40 AM · builddllbitmap

Read Files from a folder -> Load their icons as Textures

Hi,

Basic question: Why does access to some System.Drawing classes work from inside the Editor (via my own DLL file, which in turn calls System.Drawing), but not from a built standalone?

Detailed question: I am trying to create something like a filesystem inside Unity. For this, I load the Icons from files, apply them to Texture2D, and show that on some meshes.

To accomplish this, I need access to Icon and Bitmap classes (in System.Drawing). I do all this in an external DLL file. I KNOW that Unity "does not allow to access System.Drawing", but interestingly, it works perfectly fine from within the Editor. If I try to build this, it crashes on build and tells me that System.Drawing must not be included in the build. So I tried to cheat - I copied the System.Drawing.dll into the Plugins folder, and voila - the standalone gets built. But there are no textures, and the logfile shows a "TypeLoadingError" with the type "Gdip", when the

So the Icon class is working just fine, but the Bitmap class throws an error, but not in the editor.

Has, by chance, anyone got some similar problems (quite unlikely, I know) - and maybe even a solution?

I think the solution would be to [DllImport] the gdiplus.dll methods used by System.Drawing... but no luck so far.

Felix

Comment
Add comment · Show 6
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 fherbst · Jan 26, 2011 at 12:41 AM 0
Share

Boah, all this stuff sounds so strange by reading it again... but maybe someone can help, though :).

avatar image yoyo · Jan 26, 2011 at 01:36 AM 1
Share

How about avoiding System.Drawing altogether and just load a raw jpeg or png and use Texture2D.LoadImage?

avatar image Mike 3 · Jan 26, 2011 at 02:46 AM 0
Share

That doesn't work for loading icons of files though, you'd have to make a texture for every file on your computer

avatar image fherbst · Jan 26, 2011 at 11:27 AM 0
Share

I need to use System.Drawing to extract the icons associated with the files, like $$anonymous$$ike said.

avatar image yoyo · Jan 26, 2011 at 04:50 PM 0
Share

Ah, ok, I thought your files were icons, now I get it. Do you have to extract the icons dynamically, or could you preprocess them and include the icons as separate assets? (This would work cross-platform as well -- extract icons on the Windows dev box, use them anywhere ... not sure if cross-platform is a concern for you though.)

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by zeropoint · Mar 02, 2011 at 09:21 AM

Using TextAsset class would answer your question if you are trying just to load images stored as files. Here i am copying example from the TextAsset.bytes page of documentation:


// Load a .jpg or .png file by adding .bytes extensions to the file // and dragging it on the imageTextAsset

var imageTextAsset : TextAsset;

function Start () { var tex = new Texture2D (4, 4); tex.LoadImage(imageTextAsset.bytes); renderer.material.mainTexture = tex; }


from here.

Hope this suits your requirement...

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

No one has followed this question yet.

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Distribute terrain in zones 3 Answers

i want to make a easy weld tool like on gmod 0 Answers

NullReferenceException: Object reference not set to an instance of an object at QuitGameScript.OnMouseEnter () [0x00000 1 Answer

Standalone build does not find dependencies from managed plugin 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