You just create a script and put in the scene this file have for parts, follow
comment p1
using [Link];
using [Link];
using UnityEngine;
using UnityEditor;
using System;
[InitializeOnLoad]
public class EditorStartup
{
static EditorStartup()
{
// PART 1. Hi
[Link](" ------------ 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\
[Link]
// if not xist creat these folder and copy/past here your material
Material newMat = [Link]("Roof AI", typeof(Material)) as
Material;
// PART 3. WRITE YOUR GAME OBJECT instead "81_31_10"
GameObject obj = [Link]("981_31_10");
MeshRenderer[] meshs =
[Link]<MeshRenderer>();
[Link]("------------ 2. Model loaded!");
// PART 4. Assignement errors
foreach (MeshRenderer mesh in meshs)
if (newMat != null)
{
[Link] = newMat;
}
else
{
[Link](" ****************** Material not found!");
}
[Link]("------------ 3. Material is assigned !");
}
}
public class AssignMaterialSame : MonoBehaviour
{
void Start()
{
}
void Update()
{
}
}
CharacterController characterController;
// Start is called before the first frame update
void Start()
{
characterController = GetComponent<CharacterController>();
[Link] = [Link];
[Link] = false;
}
// Update is called once per frame
void Update()
{
#region Handles Movment
Vector3 forward = [Link]([Link]);
Vector3 right = [Link]([Link]);
// Press Left Shift to run
bool isRunning = [Link]([Link]);
float curSpeedX = canMove ? (isRunning ? runSpeed : walkSpeed) *
[Link]("Vertical") : 0;
float curSpeedY = canMove ? (isRunning ? runSpeed : walkSpeed) *
[Link]("Horizontal") : 0;
float movementDirectionY = moveDirection.y;
moveDirection = (forward * curSpeedX) + (right * curSpeedY);
#endregion
#region Handles Jumping
if ([Link]("Jump") && canMove &&
[Link])
{
moveDirection.y = jumpPower;
}
else
{
moveDirection.y = movementDirectionY;
}
if (![Link])
{
moveDirection.y -= gravity * [Link];
}
#endregion
#region Handles Rotation
[Link](moveDirection * [Link]);
if (canMove)
{
rotationX += -[Link]("Mouse Y") * lookSpeed;
rotationX = [Link](rotationX, -lookXLimit, lookXLimit);
[Link] = [Link](rotationX,
0, 0);
[Link] *= [Link](0, [Link]("Mouse X") *
lookSpeed, 0);
}
#endregion
}
}
It’s full code, I hope it could help you to assign the same material fo many
onjects in Unity