Unity C# : Modifying Material in Script

  Рет қаралды 19,437

about game making

about game making

Күн бұрын

Пікірлер: 52
@kermitkitchen
@kermitkitchen 2 жыл бұрын
This is easily the best video I've seen on this so far.
@aboutgamemaking
@aboutgamemaking 2 жыл бұрын
I am so happy that the tutorial really helped you. Thank you for watching! :)
@twosoulfox
@twosoulfox Жыл бұрын
Your topics and concepts are interesting. Also your older animations and ideas. I hope you can work in a good environment. Kind regards.
@aboutgamemaking
@aboutgamemaking Жыл бұрын
Thank you ! I will keep it up. :)
@ShatabdaRoy115
@ShatabdaRoy115 2 жыл бұрын
I am quite surprised how this tutorial is rich with info... Like no joke
@aboutgamemaking
@aboutgamemaking 2 жыл бұрын
I really thank you!! ,,ㅎㅅㅎ,,
@ShatabdaRoy115
@ShatabdaRoy115 2 жыл бұрын
@@aboutgamemaking whats ur discord mate?
@aboutgamemaking
@aboutgamemaking 2 жыл бұрын
@@ShatabdaRoy115 Sorry, I don't use Discord. :(
@ShatabdaRoy115
@ShatabdaRoy115 2 жыл бұрын
@@aboutgamemaking np I wish our path meet us again ;)
@aboutgamemaking
@aboutgamemaking 2 жыл бұрын
@@ShatabdaRoy115 Sure thing. I will get the Discord account when the company's work is done.
@DatCameraMON
@DatCameraMON 2 жыл бұрын
What if you aren't using a Standard material and are using a URP material?
@aboutgamemaking
@aboutgamemaking 2 жыл бұрын
Do you mean modifying material properties in URP shader? It is same as the tutorial video. As you can see the tutorial, I accessed properties' names and changed their values. Therefore, there are no differences in between standard and urp shaders.
@DatCameraMON
@DatCameraMON 2 жыл бұрын
@@aboutgamemaking Nevermind, I figured it out. You have to use: (lead up stuff).material.SetTexture("_BaseMap", (textureName)); to switch it for URP materials, I believe. In my case, I also was messing up which Renderer was assigned. I forgot that my character had a Skinned Mesh Renderer attached to the body, which was under the Player object and what I needed to assign as the Renderer variable.
@deicide2324
@deicide2324 3 жыл бұрын
Hi, what if I wanna to disable or enable all the materials in the model by click a button?
@aboutgamemaking
@aboutgamemaking 3 жыл бұрын
Do you mean remove the texture?
@deicide2324
@deicide2324 3 жыл бұрын
@@aboutgamemaking I don't think so? I am a new for unity and the model's material is applied color from Blender.
@aboutgamemaking
@aboutgamemaking 3 жыл бұрын
@@deicide2324 Ok, What you have do is, you better know what do you want to express exactly in your game. Let say about the 'Example'. Hope you understand what I'm sayng. :) Could you explain about your example?
@deicide2324
@deicide2324 3 жыл бұрын
@@aboutgamemaking Actually this is my final year project, the model consists of more than 1000 "parts" and each part has more than 1 color. What I want to do is to change all of colors in the parts to "white".
@aboutgamemaking
@aboutgamemaking 3 жыл бұрын
@@deicide2324 Alright, There many ways to change color. 1st one is change shader's property, for instance "_MainColor" or "_Color". If you use Unity's standard shader or built in shader, you can access one of shader's properties called "_MainColor". The second one is also access Standard shader's Emission and change its color. The 3rd one is change the Texture, but it might causes lots of CPU or GPU usage. In Summery, I recommend access the object's materials and shader's properties. So, you might access objects' 'Renderer' and access Renderer's Material. Actually, I'm telling you about the tutorial's content. :)
@Cherry_Dev
@Cherry_Dev 2 жыл бұрын
Where i can download the script?
@maitrykotak3703
@maitrykotak3703 Жыл бұрын
is there any helpful video for changing object like on button click new gun model come in unity..please refer
@aboutgamemaking
@aboutgamemaking Жыл бұрын
Check the tutorial down below : kzbin.info/www/bejne/fH-yaGiwbt2BZ6s
@fariahuq6473
@fariahuq6473 3 жыл бұрын
Hi! Thanks for this great tutorial! One of the best for Shader manipulation via scripting. Can you kindly tell me what is the difference between renderer.material and renderer.sharedmaterial? I sometimes encountered that renderer.material does not work correctly but renderer.sharedmaterial does.
@aboutgamemaking
@aboutgamemaking 3 жыл бұрын
1. Changing properties with 'SharedMaterial' persists the changed properties even after gameplay stops. 2. On the other hand, if you stop the game after changing the properties of a shader or material with the 'Material' command, it will return to its original state. When rendering objects, the 'SharedMaterial' of the Renderer component is used by default, but a copy of the SharedMaterial is created when using the 'Material' command. You'll have to test it out to understand this. Try creating a runtime script for two objects that use the same material, changing one to blue and the other to red. If you have tested and verified the above, it will be easier to understand. ,,ㅎㅅㅎ,,
@fariahuq6473
@fariahuq6473 3 жыл бұрын
That makes so much sense! Thanks a lot again for the detailed answer. Would love to see more of your great resources on texture and material manipulating via script 😄
@Krazion669
@Krazion669 3 жыл бұрын
Thank you for the tutorial, it was very helpful. If an object has multiple materials, how would I select which material to change? For example, my object has pupils, cornea, and irises as materials. When I click the button to change materials, it changes the pupils (which is the first material). How could I change the script to change the irises material?
@aboutgamemaking
@aboutgamemaking 3 жыл бұрын
Before I help you, I have a question. If you have multiple materials applied to your character's eyes, are the pupil, cornea, and iris as separate GameObjects?
@Krazion669
@Krazion669 3 жыл бұрын
@@aboutgamemaking No, the materials are all part of the same game object.
@aboutgamemaking
@aboutgamemaking 3 жыл бұрын
@@Krazion669 OK, applying multiple material means the material component supports array variables. Therefore, you need Renderer variable with Array, like this : Renderer[] rend; After get Renderer compornent, you will be able to access each renderer with index number, like : rend[0].material.( certain elements from material) ; or you have to test it via debug : Debug.log (rend[0].material. [ ] ); Try it and give me the result. :)
@SceneOfAction
@SceneOfAction Жыл бұрын
What a great tutorial! I tried the method you replied with for multiple mats on one object but it didn't work so I tried this and it DID! The array is already built in if you have multiple materials on one object so this line worked without changing anything else. Just add an s to material (because it's plural if there is more than one material on the object), then set the number in the material array you want to change: _renderer.materials[2].SetTexture("_MainTex", newTex); Thanks for the great tutorial!
@MayKayy
@MayKayy 10 ай бұрын
You are the best!
@eyestorm3289
@eyestorm3289 3 жыл бұрын
awesome video, thank you very much
@WerIstWieJesus
@WerIstWieJesus 2 жыл бұрын
More videos about Unity "in script" please!!!
@aboutgamemaking
@aboutgamemaking 2 жыл бұрын
I will try. ㅠㅅㅠ (crying)
@WerIstWieJesus
@WerIstWieJesus 2 жыл бұрын
@@aboutgamemaking I whish you the best.
@aboutgamemaking
@aboutgamemaking 2 жыл бұрын
@@WerIstWieJesus Thank you!
@smorazzi7494
@smorazzi7494 Ай бұрын
How can i change emission intensity via script? I can't find it. Usefull video! I hope u can upload more videos as this! Thank you!
@aboutgamemaking
@aboutgamemaking Ай бұрын
Emission, or the intensity of luminescence, is controlled by the brightness of the color. However, it would be possible to control only the intensity while maintaining a specific Emission color at runtime, but it would be a very cumbersome process. A realistic way would seem to be to create a custom shader. I will consider creating a tutorial on this issue in the future.
@StickyLabDev
@StickyLabDev Жыл бұрын
now iknow ,hope i can , _BaseMap cause i used render peplain yeah wakwak
@mandrake1017
@mandrake1017 3 жыл бұрын
Muchas gracias!!
@aboutgamemaking
@aboutgamemaking 3 жыл бұрын
¡Eres bienvenido! ¡Muchas gracias por ver mi video!
@kuhan9254
@kuhan9254 3 жыл бұрын
Nice video :)
@aboutgamemaking
@aboutgamemaking 3 жыл бұрын
Thank you ! :D
@hugodalben1738
@hugodalben1738 2 жыл бұрын
Thanks
@hydroweapon
@hydroweapon 2 жыл бұрын
Awesome
@joeywang2024
@joeywang2024 3 жыл бұрын
Great!
@aboutgamemaking
@aboutgamemaking 3 жыл бұрын
Thank you! ( ,,ㅎㅅㅎ,,)
@테이-q6z
@테이-q6z 3 жыл бұрын
GOOD!!
@aboutgamemaking
@aboutgamemaking 3 жыл бұрын
Thank you! ( ㅍㅅㅍ)
Unity C# : Character Control - Rotate and move forward
10:56
about game making
Рет қаралды 38 М.
Scripting: Change Material of an Object | Unity Tutorial
5:31
Rosscoe Tutorials
Рет қаралды 139 М.
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 20 МЛН
Unity Optimization : reducing 3D objects' draw calls
14:53
about game making
Рет қаралды 73 М.
The Dome Paradox: A Loophole in Newton's Laws
22:59
Up and Atom
Рет қаралды 974 М.
Kerbal Space Program 2 Was Murdered.
11:26
Bellular News
Рет қаралды 444 М.
Changing MATERIAL Colors in Unity [Instances & More]
5:30
SpeedTutor
Рет қаралды 115 М.
Unity C# : Costume Animation without Animator
12:18
about game making
Рет қаралды 2,5 М.
Unity C# : Changing the length of a UI image at runtime
21:39
about game making
Рет қаралды 104
What is mathematical thinking actually like?
9:44
Benjamin Keep, PhD, JD
Рет қаралды 15 М.
Unity C# : Head LookAt with using IK
15:18
about game making
Рет қаралды 14 М.
Unity C# : Free Look Camera Control Part 1 : Rotation on Mobile Devices
11:28
SCALE UNITY UI ELEMENTS FOR EVERY SCREEN RESOLUTION - CANVAS SCALER | Unity UI tutorial
9:21
BAM GAMES & APPS - Unity Tutorials
Рет қаралды 299