void OnDisable() { if (Application.isPlaying) { return; } if (mRenderer != null) { mRenderer.sharedMaterials = MaterialReplace.Replace(mRenderer.sharedMaterials); } mDynamicMat = null; mMaterial = null; }
void SetMaterials(Material[] mats) { mMaterial = MaterialReplace.Replace(mats); for (int i = 0; i < mMaterial.Length; ++i) { if (mMaterial[i] == null && mMatGUIDs.Count > i) { string guid = mMatGUIDs[i]; mMaterial[i] = (Material)UnityEditor.AssetDatabase.LoadAssetAtPath(UnityEditor.AssetDatabase.GUIDToAssetPath(guid), typeof(Material)); } } mMatGUIDs.Clear(); foreach (Material mat in mMaterial) { string path = UnityEditor.AssetDatabase.GetAssetPath(mat); mMatGUIDs.Add(UnityEditor.AssetDatabase.AssetPathToGUID(path)); } }