private bool _DrawChildControl(SECTR_LOD myLOD, SECTR_LOD.LODSet lodSet, Transform transform, bool hasChildren) { string undoString = "Changed LOD"; bool expanded = false; float labelWidth = Screen.width * 0.3f; float checkWidth = 30; float buffer = 5; Rect propertyRect = EditorGUILayout.BeginHorizontal(GUILayout.Width(labelWidth)); if (hasChildren) { hierarchyFoldouts.TryGetValue(transform, out expanded); hierarchyFoldouts[transform] = EditorGUILayout.Foldout(expanded, transform.name); } else { EditorGUILayout.LabelField(transform.name, GUILayout.Width(labelWidth)); } EditorGUILayout.EndHorizontal(); SECTR_LOD.LODEntry entry = lodSet.GetEntry(transform.gameObject); bool isChecked = entry != null; bool newChecked = GUI.Toggle(new Rect(propertyRect.xMax + buffer, propertyRect.y, checkWidth, propertyRect.height), isChecked, GUIContent.none); if (newChecked != isChecked) { SECTR_Undo.Record(myLOD, undoString); if (newChecked) { entry = lodSet.Add(transform.gameObject, null); } else { lodSet.Remove(transform.gameObject); entry = null; } isChecked = newChecked; myLOD.Reset(); } if (entry != null && transform.GetComponent <Renderer>()) { Renderer newSource = (Renderer)EditorGUI.ObjectField(new Rect(propertyRect.xMax + checkWidth + buffer, propertyRect.y, Screen.width - (propertyRect.xMax + checkWidth + buffer * 2), propertyRect.height), GUIContent.none, entry.lightmapSource, typeof(Renderer), true); if (newSource != entry.lightmapSource) { SECTR_Undo.Record(myLOD, undoString); entry.lightmapSource = newSource; myLOD.Reset(); } } return(expanded); }
public void OnDisable() { SECTR_LOD myLOD = (SECTR_LOD)target; myLOD.Reset(); }