After updating my unity to 5.4, I had serious problem with the new update including LineRenderer no longer working the way it worked before but my question here is about all my sprites that used the Deualt Sprite Material that got changed to Null, Now I thought I could be clever and repair it efficiently by writing a code to run in edit mode to find all those materials that got changed by the update back to default
but the code I wrote wont even run in the editor, can anyway tell me why this code wont run because i get no error from it.
this is the code here:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class FindMaterialRepair : MonoBehaviour {
public Material mat;
private List<SpriteRenderer> list = new List<SpriteRenderer>();
private SpriteRenderer[] Arr;
[ExecuteInEditMode]
void Update ()
{
Arr = transform.GetComponentsInChildren<SpriteRenderer>();
foreach(SpriteRenderer s in Arr)
{
if(s.material.name == "None (Material)")
{
list.Add(s);
}
}
for(int x = 0; x < list.Count; x++)
{
list[x].material = mat;
}
}
}