using System.Collections.Generic; using UnityEngine; using System; using UnityEngine.Experimental.Rendering; namespace UnityEditor.Rendering { /// /// Material upgrader and relevant utilities for SpeedTree 9. /// public class SpeedTree9MaterialUpgrader : MaterialUpgrader { /// /// Postprocesses materials while you are importing a SpeedTree 9 asset. Call from OnPostprocessSpeedTree in a MaterialPostprocessor. /// /// The GameObject Unity creates from this imported SpeedTree. /// Render pipeline-specific material finalizer. protected static void PostprocessSpeedTree9Materials(GameObject speedtree, MaterialFinalizer finalizer = null) { LODGroup lg = speedtree.GetComponent(); LOD[] lods = lg.GetLODs(); for (int l = 0; l < lods.Length; l++) { LOD lod = lods[l]; foreach (Renderer r in lod.renderers) { foreach (Material m in r.sharedMaterials) { if (m == null) continue; if (finalizer != null) finalizer(m); } } } } } }