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 NerdMaromba · Jan 22, 2014 at 06:23 AM · loadimage

Can't get LoadImage working

I need to open a image and transform to byte to run by LoadImage here is my code:

Texture2D defaultMapTexture = new Texture2D(512, 512, TextureFormat.ARGB32, false);

string completedPath = "file://C:/a.bmp";

byte [] textureData = File.ReadAllBytes(completedPath);

defaultMapTexture.LoadImage(textureData);

defaultMapTexture.Apply();

Rect rect = new Rect(20f, 20f, 1106, 906);

GUI.DrawTexture(rect, defaultMapTexture);

Comment
Add comment · Show 1
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 numberkruncher · Jan 22, 2014 at 12:53 PM 0
Share

Have you tried using a PNG file since I do not think that B$$anonymous$$P files are supported by this function?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by nRadiant · Jan 22, 2014 at 03:05 PM

numberkruncher is right... Documentation says:

This function loads a JPG or PNG image from raw byte[] array

Here is the documentation that says that you need JPG or PNG

Convert to jpg or png and you will be good to go.

Comment
Add comment · Show 1 · 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 NerdMaromba · Jan 22, 2014 at 04:01 PM 0
Share

I have converted to PNG and JPG, nothing works, it only show me a alpha white, like with B$$anonymous$$P image :(

avatar image
0

Answer by poncho · Jan 22, 2014 at 05:13 PM

not sure if file's location is relevant, but you could add it to your assets folder and use Resources.Load, if it does not gives you the texture, try with the file a.PNG moving it to assets/Resources

Texture2D myTexture = Resources.Load("a.PNG") as Texture2D;

then draw it where you want it.

GUI.DrawTexture(rect, myTexture);

Comment
Add comment · Show 3 · 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 NerdMaromba · Jan 22, 2014 at 06:54 PM 0
Share

I'm a beginner, can you tell me where is Assets folder?

avatar image NerdMaromba · Jan 22, 2014 at 07:41 PM 0
Share

With WWW it loads, but cause huge FPS drop :(

avatar image poncho · Jan 22, 2014 at 09:05 PM 0
Share

Assets folder is where everything you send to project window(not hierarchy) lives, right click on anything in your project window, go to source folder, or any one with similar message, root folder, origin, explore, not sure

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

21 People are following this question.

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

Related Questions

A node in a childnode? 1 Answer

Play Services Plugin Google ID doesn't update 0 Answers

Control basics - NGUI 1 Answer

Is it legal to sell a game made with free unity under the following circumstances? 3 Answers

Selecting and Placing objects from GUI 1 Answer


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