public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label) { SerializedProperty serializedProperty = prop.FindPropertyRelative("defaultValue"); SerializedProperty serializedProperty2 = prop.FindPropertyRelative("exposedName"); string text = serializedProperty2.stringValue; BaseExposedPropertyDrawer.ExposedPropertyMode exposedPropertyMode = BaseExposedPropertyDrawer.GetExposedPropertyMode(text); Rect rect = position; rect.xMax -= BaseExposedPropertyDrawer.kDriveWidgetWidth; Rect position2 = position; position2.x = rect.xMax; position2.width = BaseExposedPropertyDrawer.kDriveWidgetWidth; IExposedPropertyTable exposedPropertyTable = this.GetExposedPropertyTable(prop); bool flag = exposedPropertyTable != null; PropertyName propertyName = new PropertyName(text); BaseExposedPropertyDrawer.OverrideState overrideState = BaseExposedPropertyDrawer.OverrideState.DefaultValue; UnityEngine.Object currentReferenceValue = this.Resolve(propertyName, exposedPropertyTable, serializedProperty.objectReferenceValue, out overrideState); Color color = GUI.color; bool boldDefaultFont = EditorGUIUtility.GetBoldDefaultFont(); Rect position3 = this.DrawLabel(flag, overrideState, label, position, exposedPropertyTable, text, serializedProperty2, serializedProperty); EditorGUI.BeginChangeCheck(); if (exposedPropertyMode == BaseExposedPropertyDrawer.ExposedPropertyMode.DefaultValue || exposedPropertyMode == BaseExposedPropertyDrawer.ExposedPropertyMode.NamedGUID) { this.OnRenderProperty(position3, propertyName, currentReferenceValue, serializedProperty, serializedProperty2, exposedPropertyMode, exposedPropertyTable); } else { position3.width /= 2f; EditorGUI.BeginChangeCheck(); text = EditorGUI.TextField(position3, text); if (EditorGUI.EndChangeCheck()) { serializedProperty2.stringValue = text; } position3.x += position3.width; this.OnRenderProperty(position3, new PropertyName(text), currentReferenceValue, serializedProperty, serializedProperty2, exposedPropertyMode, exposedPropertyTable); } EditorGUI.EndDisabledGroup(); GUI.color = color; EditorGUIUtility.SetBoldDefaultFont(boldDefaultFont); if (flag && GUI.Button(position2, GUIContent.none, BaseExposedPropertyDrawer.kDropDownStyle)) { GenericMenu genericMenu = new GenericMenu(); this.PopulateContextMenu(genericMenu, overrideState, exposedPropertyTable, serializedProperty2, serializedProperty); genericMenu.ShowAsContext(); Event.current.Use(); } }
protected abstract void OnRenderProperty(Rect position, PropertyName exposedPropertyNameString, UnityEngine.Object currentReferenceValue, SerializedProperty exposedPropertyDefault, SerializedProperty exposedPropertyName, BaseExposedPropertyDrawer.ExposedPropertyMode mode, IExposedPropertyTable exposedProperties);
protected override void OnRenderProperty(Rect position, PropertyName exposedPropertyNameString, UnityEngine.Object currentReferenceValue, SerializedProperty exposedPropertyDefault, SerializedProperty exposedPropertyName, BaseExposedPropertyDrawer.ExposedPropertyMode mode, IExposedPropertyTable exposedPropertyTable) { Type objType = base.fieldInfo.FieldType.GetGenericArguments()[0]; EditorGUI.BeginChangeCheck(); UnityEngine.Object @object = EditorGUI.ObjectField(position, currentReferenceValue, objType, exposedPropertyTable != null); if (EditorGUI.EndChangeCheck()) { if (mode == BaseExposedPropertyDrawer.ExposedPropertyMode.DefaultValue) { if (!EditorUtility.IsPersistent(exposedPropertyDefault.serializedObject.targetObject) || @object == null || EditorUtility.IsPersistent(@object)) { if (!EditorGUI.CheckForCrossSceneReferencing(exposedPropertyDefault.serializedObject.targetObject, @object)) { exposedPropertyDefault.objectReferenceValue = @object; } } else { string text = GUID.Generate().ToString(); exposedPropertyNameString = new PropertyName(text); exposedPropertyName.stringValue = text; Undo.RecordObject(exposedPropertyTable as UnityEngine.Object, "Set Exposed Property"); exposedPropertyTable.SetReferenceValue(exposedPropertyNameString, @object); } } else { Undo.RecordObject(exposedPropertyTable as UnityEngine.Object, "Set Exposed Property"); exposedPropertyTable.SetReferenceValue(exposedPropertyNameString, @object); } } }