- Home /
Adding Materials to an object.
So I created an object which is a cube, I want this cube to have transparency so I could see through it. What I did was create a material called Transparent and set its Rendering mode to transparent and also selected Albedo and dragged the A value far to the left so that it is transparent. On Scene when I manually create a cube and add the component it is see through. So I then add this to a script which instantiates cubes and what I want is to also add this transparent material component at the same time. However on scene play it comes out as purple and not transparent at all. I do not know why . Here is how I add the code for material in the script.
public Material Transparent;
object.GetComponent<Renderer>().material = Transparent;
I have also tried making a new script, and in this new script I added public material and added the material as well
public Material Transparent;
void Start (){
GetComponent<Renderer>().material = Transparent;
}
And then I add the the new script to the scene and then drag my material to the material under the script and when I run the material is still not transparent and purple still. Is there something wrong in my material or script? I notice when I run the scene with the added script under my object, Transparent is appearing with None(Material) selected. Here is a link to how I have my material. https://imgur.com/a/cuy5dnR
Answer by LulaCD · Sep 19, 2020 at 04:36 PM
I'm gonna link two videos here because they do a better job than i ever would.
Your answer
Follow this Question
Related Questions
How do I disable shadows being casted from a transparent material? 1 Answer
What is better to do in my case in my game 1 Answer
Occlusion, hiding an object within a transparent box. 0 Answers
Cannot change Materials of certain objects 1 Answer
Shader to turn materials transparent based on y axis 0 Answers