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 Samael_00001 · May 07, 2014 at 11:16 AM · c#texturetextcube

How to display text on a cube and how to change it dynamically?

Comment
Add comment · Show 2
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 NickP_2 · May 07, 2014 at 01:00 PM 0
Share

3d, 2d? We need more info

avatar image Samael_00001 · May 07, 2014 at 01:08 PM 0
Share

2D, but I'm using 3D figures. I want to fill this cube with some color and to add a text at a center.. how to do that?

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Owen-Reynolds · May 07, 2014 at 03:27 PM

Paste (child) a 3DText over it. Change it the usual way for 3DText (also called TextMeshes.)

The other way, changing the cube texture itself, would be a huge pain. Have to fix the unwrap (the Unity cube assigns entire texture to each face,) and so on.

Comment
Add comment · Show 4 · 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 Samael_00001 · May 07, 2014 at 03:46 PM 0
Share

Hah, changing the cube texture IS what I'm after, probably.. and there's no need to fix the unwrap, it's fine.

I've been thinking about smthg like this:

 Texture2D texture = null;
                     Color fillColor = new Color (1, 0.0f, 0.0f);
                     Color[] fillColorArray = texture.GetPixels ();
                     
                     for (int m=0; i<fillColorArray.Length; ++m) 
                     {
                         fillColorArray[i] = fillColor;
                     }
                     
                     texture.SetPixels (fillColorArray);
                     texture.Apply ();
                     material.mainTexture = texture;
 
                     GameObject.Find("object_name").transform.renderer.material = material;
 
                 
avatar image Samael_00001 · May 07, 2014 at 04:02 PM 0
Share

but how to put a text into that texture? And how to do all this from a code?

avatar image Owen-Reynolds · May 07, 2014 at 09:31 PM 0
Share

Well, like I said, I think putting it directly on the texture would be a huge pain. There's no easy way to access a letter texture, much less a whole word; or put it on only 1 side; or scale/rotate/position the word pixels onto the mainTexture pixels.

If you have a few fixed phrases, most people would just pre-make textures with those, get them all nice, and swap textures (or even materials) in-game.

avatar image robertbu · May 08, 2014 at 12:53 AM 1
Share

Older material, but it should still work:

http://blog.almostlogical.com/2010/08/20/adding-text-to-texture-at-runtime-in-unity3d-without-using-render-texture/

avatar image
1

Answer by i1drago · Apr 19, 2017 at 03:58 PM

Old post but I thought others might get helped by my finding:

http://geek1337.blogspot.se/2017/04/unity3d-creating-cube-with-text-on-each.html

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

24 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 avatar image avatar image avatar image

Related Questions

How to create a texture, fill it with some color, add a text at a center and to set this texture to some object in C#? 0 Answers

C# GUI Button 2 Answers

A node in a childnode? 1 Answer

C# cannot convert 'char' expression to type 'UnityEngine.Texture' 1 Answer

GUI text disapearing randomly. 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