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 Lord Simpson · Feb 26, 2012 at 05:33 PM · texture2dtransparentunity3.5

Unity 3.5 New texture2D not transparent

Hi just upgraded my project to 3.5 and found out that when creating a new texture2d the default colour is white not transparent like 3.4.

Is there an easy way to change every pixel to transparent before I start creating my texture? Should also mention I don't know the dimensions of the texture until its being created so don't think I can just get all the pixels from a transparent texture of the same size.

Its a shame the constructor doesn't have a background colour option.

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
2
Best Answer

Answer by Eric5h5 · Feb 26, 2012 at 09:01 PM

There isn't any default color and never was; the pixels in a new Texture2D are always empty (i.e., undefined).

 var tex = new Texture2D(64, 64);
 var texColors = new Color32[64 * 64];
 for (color in texColors) color = Color.clear;
 tex.SetPixels32 (texColors);
 tex.Apply();
Comment
Add comment · Show 6 · 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 Lord Simpson · Feb 26, 2012 at 09:25 PM 0
Share

just worried about the speed of that operation since at times I may be generating textures multiple times a second. As for the default colour, all I know is in 3.4 the pixels I hadn't set where transparent now there white [shrug]

avatar image Eric5h5 · Feb 26, 2012 at 09:38 PM 0
Share

As I said, the pixels are undefined. They might be transparent, or white, or whatever, depending on whatever happens to be in memory. The speed is trivial, and you could make thousands of textures per second...except for the tex.Apply() part. When you create a texture, it has to be uploaded to the graphics card, which can take a relatively long time for larger textures. I don't know what you're doing, but you might want to use rendertextures ins$$anonymous$$d.

avatar image Lord Simpson · Feb 26, 2012 at 09:56 PM 0
Share

Cant use render texture as I'm currently using free, (Basically since I cant think of a better way to do it) I have a texture with number images 0-9 in, I'm using GetPixels grab the numbers and set pixels to place them into a new texture2D, applying once all the sets are complete then using it in a newly instantiated particle system to draw a floating damage number (tried a GUIText method but it refused to look good)

avatar image Eric5h5 · Feb 26, 2012 at 10:11 PM 0
Share

Actually I'd strongly recommend GUIText ins$$anonymous$$d. I did something similar quite a while ago (http://www.starscenesoftware.com/tmfppg.html if you have a $$anonymous$$ac); there's no reason you can't get it to look good.

avatar image Lord Simpson · Feb 26, 2012 at 10:16 PM 0
Share

problem with GUIText is i cant get it to look great in 3D im going for a borderlands style effect, the particle system has been the best so far and was working fine untill 3.5. Guess ill have to try and find another way of doing it, or some other work around the get the background transparent.

Show more comments
avatar image
-2

Answer by ayeni2ify · Feb 26, 2012 at 10:52 PM

you are gonna have to use photoshop which can be downloaded here and that will solve your problem.

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

6 People are following this question.

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

Related Questions

ingame transparency 2 Answers

Check if every pixel of a texture is transparent 1 Answer

Can I get Direct3D pointer of Texture2D in Unity3.5? 8 Answers

EncodeToPng that works more smoothly on mobile 1 Answer

async texture apply (WebPlayer) 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