void OnGUI() { if (DesignerObject == null) { return; } var control = DesignerObject as Control; if (control != null && (control.Disposing || control.IsDisposed) || !UnityEngine.Application.isPlaying) { DesignerObject = null; return; } scrollPosition = GUILayout.BeginScrollView(scrollPosition); if (designer == null || designer.Value != DesignerObject) { designer = new ObjectDesigner(DesignerObject); } var newObject = designer.Draw((int)position.width - 8, int.MaxValue); if (newObject != null) { DesignerObject = newObject; } GUILayout.EndScrollView(); }