how should I go about implementing a digital clock display. I see potentially 3 solutions:
4 planes, and 10 materials for the 10 digits and just assign to each plane the relevant material. Which one is more efficient here: having 10 materials (one for each digit) and assign materials to the planes or having 4 materials and assign Textures to the materials?
1 plane, and 1 texture that is build dynamically with the Texture2D class
using a digital clock font and gui text. Not sure if this will work at all since I want to be changing the position of the display relative to the camera
I already implemented solution 1 since it is the most straightforward one but it is 4 draw calls.
Are the other solutions feasible at all?
Would they be worth it in terms of performance?
Maybe there is yet another solution that I am missing?
Unfortunately it doesn’t work in my case for the following reasons:
as I move the camera, the text moves as well. I need it to stay fixed on the display
it is rendered on top of the objects in the scene.
Overall doesn’t look good. I can’t change the color since it’s grayed out and 1:11 is spaced differently than 2:22 (this I guess depends on the font, but it would be hard to find one that uses the same space for all characters)
If I have to choose between 1 and 2 which is more efficient?
If I want to change a texture, which one is better, assigning a new material to the mesh, or assigning a new texture to the mesh’s material?
I would like to know this, since it arises quite often, not just in this situation.
I thought you did want it to move, based on what you said for #3. If you want it to stay fixed, you can make it a child of the camera. But in that case, you might as well just use a GUIText. For being rendered on top of objects in the scene (oops, guess you don’t want a GUIText after all…), you can change the material of the 3D text to use a different shader. Using a different material would also fix not being able to change the color. If you use a mono-spaced font, that would fix the spacing problems.
Thanks again Eric. By the way, for me is an honor that you replied to my thread
Yes, I want the text to stay fixed on the display but change relative to the camera, which using 3D Text accomplishes like you said. I didn’t see this at first, because the text was way behind my object, even though it was rendered on top of it.
Anyway, my only remaining problem is that the text is rendered on top of everything. I tried changing the shader, but the only one that displays something on screen is the GUI/Text Shader.
What shader should I use?
Before you suggest it, I can’t write my own shader
Actually I don’t think any of the built-in shaders would really work. If you change the Ztest stuff in the GUI/Text shader so it’s not always on top, that would do it, like this:
Shader "GUI/3D Text Shader" {
Properties {
_MainTex ("Font Texture", 2D) = "white" {}
_Color ("Text Color", Color) = (1,1,1,1)
}
SubShader {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
Lighting Off Cull Off ZWrite On Fog { Mode Off }
Blend SrcAlpha OneMinusSrcAlpha
Pass {
Color [_Color]
SetTexture [_MainTex] {
combine primary, texture * primary
}
}
}
}