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
2
Question by Skjalg · Apr 18, 2011 at 09:41 AM · guipixelopengloptimizing

How can I draw one black pixel in GUI

What is the most optimized way of drawing one black pixel in my GUI and how do I achieve that?

This is my attempt, but it does not show anything (requires unity pro):

GL.Begin(GL.LINES);
GL.Color(new Color(0, 0, 0));
GL.Vertex3(drawPosition.xMin, drawPosition.yMin, 0);
GL.End();
GL.PopMatrix();
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

2 Replies

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

Answer by Mortennobel · Apr 18, 2011 at 10:00 AM

I would think it is much more efficient to draw on a texture, and then draw the texture on the screen. But it depends on how many pixels you are painting and how often you update your pixels.

Take a look at these two methods:

http://unity3d.com/support/documentation/ScriptReference/Texture2D.SetPixel.html

http://unity3d.com/support/documentation/ScriptReference/GUI.DrawTexture.html

Anyway the reason your code does not work is that you are trying to draw a line of only one point (which means a line of length 0 which equals nothing). You could try to use GL.Begin(0); instead (meaning GL_POINTS - but there is no unity wrapper for this .. most likely for a reason, so it may not work)

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
2

Answer by CHPedersen · Apr 18, 2011 at 10:39 AM

Texture2D.SetPixel does the trick indeed, but make sure you don't do this repeatedly in real-time. SetPixel is in itself not particularly fast, and to make matters worse it must be followed by a call to Texture2D.Apply, which uploads the texture to the graphics card so it can be displayed. Uploading textures is exceptionally costly because it's limited by bus bandwidth, so don't do that unless absolutely necessary.

You seem to have unity pro, which gives you render textures. Consider using them and a camera to render a dot onto a texture, then display that instead. This ensures the texture is created at the graphics card's side, which is must faster.

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

Thin Line on top of GUI 0 Answers

Changing pixel inset of GUI texture from scripting 1 Answer

how to render line between gui element and mouse position 1 Answer

full screen wide GUI.Box 3 Answers

How do I scale GUI Text but while keeping it "pixel correct"? 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