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 LukeArCo · Dec 08, 2014 at 10:01 PM · numbercolournumbers

How do I convert pixel colours to numbers?

I want to create a level creator for my game but I can't figure out how I will set it so the game will read the image file and then convert each pixels colour as a number.

I've got a script that creates objects from numbers it's just the colour to number/text format that I can't figure out.

Comment
Add comment · Show 4
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 NoseKills · Dec 08, 2014 at 10:01 PM 0
Share

the game will read the colour file

You mean an image?

You can get the pixel color in an image with Texture.GetPixels(x,y,w,h);

 Color[] temp = myTexture.GetPixels(x,y,w,h);

Then you'll just have to create a system to match a color to a number how ever you want to do it.

You are not giving too much details in your question...

avatar image LukeArCo · Dec 09, 2014 at 10:42 AM 0
Share

Basically what I mean is I would draw an image up and then unity would read the image and convert each colour into a specific number in something like a text file, so if unity read a blue pixel it would export a 1 into a text file, then if it read yellow it would export 2 into a text file

Sorry for not giving that much detail

avatar image PvTGreg · Dec 09, 2014 at 11:31 AM 0
Share

why do you need to convert it into a number?

avatar image LukeArCo · Dec 09, 2014 at 11:58 AM 0
Share

$$anonymous$$y script takes numbers and instantiates blocks at the same position as the number is in the text file and from what I know the way I've done it won't work with colours and I can't figure out a way to get it working with colours

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by PvTGreg · Dec 09, 2014 at 02:50 PM

http://answers.unity3d.com/questions/798859/randomly-generateplace-map-peices.html this is from one of my questions a while back maybe it is of some use

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 LukeArCo · Dec 17, 2014 at 01:36 PM 0
Share

Thank you for showing me this it worked gloriously!

avatar image
0

Answer by NoseKills · Dec 09, 2014 at 11:57 AM

Texture.GetPixels() can be used for your purpose. Assign the image to a variable of type Texture in the inspector. Use GetPixels() to read the pixel colors. Then you'll just have to make the conversion to number if (pixelColor == Color.white){...}

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

how do i store a really big number? 2 Answers

Turn numlock on at start 2 Answers

Golf swinging gauge - Techanically any type of recepricating gauge. 0 Answers

Large number of objects problem 1 Answer

Random gen script giving same numbers 3 times in a row 3 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