cant set material in UI text - c#

I want to change my text color after sometime and want to continue the process. I was trying to do that by changing the material color.but the text gets filled up when I am trying to add a material on it. here's the image which will help you to understand.The first one is without a material and the second one is with a material.

You can use a user defined material for the UI. The reason you see a blcock shaped image instead of your Text is because of the shader of the Material. You cannot use the Standard shader or any shader not intended to be used for the UI. You must use the shader under the UI shader menu.
Select your scoreMat Material and change its shader to UI ---> Default shader.

Related

Is there any way to render an object while standing in it?

I have a first person controller and currently if I walk into a slightly transparent object, it disappears until I walk out of it.
I have a 'water' cube object that is very light blue and transparent, and when I move my camera into third person view then enter the water, my screen turns light blue which is good. In first person mode (which is what I'm trying to figure out), the cube disappears and my screen color remains the same.
I know it has something to do with my camera but even after going through all the features on unity docs and changing a few settings in the inspector, it all remains the same.
Like mentioned in the comments your cube is not visible because the backside of its faces is being culled, meaning they are not rendered. This is not a camera setting but a property of the shader your water cubes material is using.
You could create get a duplicate of the shader your are using where you add Cull Off to change this.
Read about it here.
If you want to go that route you need the source files for your shader. Assuming it is one of the Unity Built in shaders you can get them from the Unity Download archive here for your Unity version.
Clipping the camera trough objects is rarely a desired and you should look at a different way of achieving your effect like using a post-processing volume because the "water" would still be a cube and be drawn behind everything in front of its faces.
For example in a FPS type game this would result in the gun not changing color.

Making Materials Transparent in Unity

So I'm trying to add an effect to a game object where the transparency of its materials will grow over time until it hits a threshold, then go back to normal, and repeat for a predetermined amount of time. I made it so I can make them transparent after a bit of research, but my issue is now just trying to use the best transparent shader.
I first used the UI/Unlit/Transparent shader where I could just grab the alpha value and increment/decrement it as I wanted and made it go transparent, but my issue was that the tint of that material would make it blindingly white, which I don't know if I can do anything about since I am using PNGs as the material so I can't just edit the tint to not affect the material I think.
Then I used the Unlit/Transparent shader but that only has _MainText or Diffuse, which doesn't have a way to edit the transparency without a custom shader is what I've found after scrolling through Unity Answers and other StackOverflow posts.
Is my only option to write a custom shader for Diffuse to get this to work or is there something obvious that I'm missing for these shaders?
Alright I figured out that all I had to do was check off the "Use Alpha Clip" option on the UI/Unlit/Transparent shader and it only uses the alpha variable and not the tint

How do I add transparency to a diffuse mesh renderer?

I've been trying to implement a door for my game but when I change the material to the open door material I get a result like this:
These are the settings for the material:
I would like to be able to have an open door with normal transparency instead of this weird glitch. Any help would be much appreciated.
I figured out the solution and it's quite simple! The shader needed to be Legacy Shaders/Transparent/Cutout/Diffuse. My shader was Legacy Shaders/Diffuse,
You might not need to change the shader. In the unity's standar shader if the render mode is changed to transparent then the change in the color's alpha takes place in the game.
It usually happens that the alpha change does not work when it is changed in the color palette because the render mode needs to be changed from the opaque mode for the tranparency to work.

How to fix console error in Unity 5

I'm newbie in Unity & I wanted to add a water to my scene but the water that I added looks purple and I got two error messages as well in my console which says:
Material Does Not Have A Color Property
So how to fix this issue ? There must be a problem with my shader texture however the material has the write texture.. Print Screens Are Below:
That's the graphics card's way of telling you it doesn't know which shader to apply your object.
Click on a mesh that is pink, and the material property will be set to none or missing. You'll need to remap the materials in your project to your pink objects, or drag the textures back onto your objects again.
You are seeing this pink color because a shader is missing or is not properly selected.
I'm sure the following is the error you'd encounter in the inspector:
This is how it should look if everything is correct:
I selected the shader in the file browser so you can check the location yourself.
Resolving the issue
The first thing you could try to resolve this issue is open the shader tab in the inspector and search the "Shader" dropdown menu for the water shader:
If you can't find it there the only option is to reimport the assetpack.
Or copy this shader from another project where you still have it.

Sprites drawing over text in unity

I am trying to display the score for my game, however, my background sprite is drawing right over it. I have tried assigning some type of layer tag but I can't find one for text. Everything I try, the text is always hidden under the sprite for my background (and any other sprite for that matter). Is there a way to assign the text to be drawn over everything, I have tried looking at tons of sites in hopes of a fix but I can't seem to find anything. Any help is extremely appreciated.
From the hierarchy creation menu, pick UI->Text
This will add you 3 Elements to the hierarchy: Canvas, and 2 child gameobjects which are Text and EventManager. These are all needed for the proccess.
The text gameobject is part of the UI system Unity has, means that if done correctly, it should show over all sprites.
Programmatically you can change text by simply saying:
myUItext.text = "Text that will show on UI!"
Manually you can change position, font and text using the hierarchy view.
For further details use this video from the official Unity tutorial

Categories