- Home /
Skinned Mesh Renderer Material
I have add several materials to the Skinned Mesh Renderer Node of an animated FBX file.
But I can't seem to switch the materials. Keep running into this error among others:
An instance of type 'UnityEngine.Renderer' is required to access non static member
I have a simple Java Script attached to the same node with:
renderer.materials = SkinnedMeshRenderer.materials[skinChoice];
I've also tried using shared.materials
What is the proper method to change textures and materials on animated fbx files?
Answer by MrBurns · Dec 12, 2010 at 11:24 AM
//#1 var Material1 : Material; var Texture1 : Texture;
//#2 var Material2 : Material; var Texture2 : Texture;
function update(){
if() { GameObject.Find("object").renderer.sharedMaterial = Material1; GameObject.Find("object").renderer.material.mainTexture = Texture1; } else GameObject.Find("object").renderer.sharedMaterial = Material2; GameObject.Find("object").renderer.material.mainTexture = Texture2;
}
This should work, if this is what you wanted to do? Change the material and texture of an object?
This is awesome! I am trying to make a button that will change the material on my character...
I have this
================================
var material1 : $$anonymous$$aterial;
function Update () {
for (GUI.Button(Rect(Screen.width - 74,148,64,64)))
{ GameObject.Find("joint1").renderer.shared$$anonymous$$aterial = material1; } }
================================
It tells me my line where i draw the gui button is wrong... what's up with that?
Sorry for the formatting... it automatically adjusts to that :S
Every GUI code must be inside of the OnGUI () method not the the Update().
Your answer
![](https://koobas.hobune.stream/wayback/20220613071057im_/https://answers.unity.com/themes/thub/images/avi.jpg)