// On destroy void OnDestroy() { if (s_Instance != null) { try { if (m_PlaneRenderers != null) { foreach (MeshRenderer r in m_PlaneRenderers) { if (r != null && r.gameObject != null) { GameObject.Destroy(r.gameObject); } } } if (m_PlaneMaterials != null) { foreach (Material mat in m_PlaneMaterials) { if (mat != null) { Material.Destroy(mat); } } } } catch (Exception e) { Debug.Log("VCMatGenerator OnDestroy have some problem" + e.ToString()); } s_Instance = null; } }
// Use this for initialization void Awake() { s_Instance = this; }