All the search results I got were from 2012 and earlier and most of them are deprecated.
I am trying to set a texture to 200 game objects using a simple class however I am having a hard time accessing the appropriate component.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class SM_Bld_Texture
{
[MenuItem("Tools/Assign BLD Texture")]
public static void AssignTileMaterial()
{
GameObject[] tiles = GameObject.FindGameObjectsWithTag("SM_Bld");
Texture texture = Resources.Load<Texture>("T_PolygonTown_01_A");
foreach (GameObject t in tiles)
{
t.GetComponent<MeshRenderer>().material.SetTexture("T_PolygonTown_01_A", texture);
}
}
}
I am a bit at a loss… am I even accessing the right component?