0% found this document useful (0 votes)
10 views

Assign Material in view Unity part 2

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Assign Material in view Unity part 2

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

You just create a script and put in the scene this file have for parts, follow

comment p1
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System;

[InitializeOnLoad]
public class EditorStartup
{
static EditorStartup()
{
// PART 1. Hi

Debug.Log(" ------------ Wellcome to Scrip to change multiple objects


------------");

// PART 2. WRITE YOUR MATEARIAL instead "Roof AI" your material,


// if it's pink chack that yor material exits in Assets\Resources\
YourMaterial.mat
// if not xist creat these folder and copy/past here your material
Material newMat = Resources.Load("Roof AI", typeof(Material)) as
Material;

// PART 3. WRITE YOUR GAME OBJECT instead "81_31_10"


GameObject obj = GameObject.Find("981_31_10");
MeshRenderer[] meshs =
obj.GetComponentsInChildren<MeshRenderer>();

Debug.Log("------------ 2. Model loaded!");


// PART 4. Assignement errors
foreach (MeshRenderer mesh in meshs)
if (newMat != null)
{
mesh.material = newMat;
}
else
{
Debug.LogError(" ****************** Material not found!");
}
Debug.Log("------------ 3. Material is assigned !");
}
}

public class AssignMaterialSame : MonoBehaviour


{
void Start()
{
}
void Update()
{
}
}
CharacterController characterController;
// Start is called before the first frame update

Next part you will find in file which are the part 3

You might also like