protected void SurfaceField(string label, ref string field, bool dirtyMesh = true) { if (_surface?.name != field) { _surface = null; } var mb = target as MonoBehaviour; if (_surface == null && _table != null) { string currentFieldName = field; if (currentFieldName != null && _table.Table.Has <Surface>(currentFieldName)) { _surface = _table.gameObject.GetComponentsInChildren <SurfaceBehavior>(true) .FirstOrDefault(s => s.name == currentFieldName); } } EditorGUI.BeginChangeCheck(); _surface = (SurfaceBehavior)EditorGUILayout.ObjectField(label, _surface, typeof(SurfaceBehavior), true); if (EditorGUI.EndChangeCheck()) { FinishEdit(label, dirtyMesh); field = _surface != null ? _surface.name : ""; } }
protected override void OnEnable() { base.OnEnable(); _targetSurf = target as SurfaceBehavior; }