public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { Rect propertyDrawRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); bool isArrayElement = property.IsArrayElement(); if (!isArrayElement) { EditorGUI.LabelField(propertyDrawRect, label); propertyDrawRect.y += propertyDrawRect.height; propertyDrawRect.x += 40; propertyDrawRect.width -= 40; } SerializedProperty nameProperty = property.FindPropertyRelative("name"); EditorGUI.PropertyField(propertyDrawRect, nameProperty); propertyDrawRect.y += propertyDrawRect.height; SerializedProperty typeProperty = property.FindPropertyRelative("paramType"); EditorGUI.PropertyField(propertyDrawRect, typeProperty); LuaParamType paramType = (LuaParamType)typeProperty.intValue; propertyDrawRect.y += propertyDrawRect.height; if (paramType == LuaParamType.Integer) { SerializedProperty valueProperty = property.FindPropertyRelative("intValue"); EditorGUI.PropertyField(propertyDrawRect, valueProperty); } else if (paramType == LuaParamType.Float) { SerializedProperty valueProperty = property.FindPropertyRelative("floatValue"); EditorGUI.PropertyField(propertyDrawRect, valueProperty); } else if (paramType == LuaParamType.String) { SerializedProperty valueProperty = property.FindPropertyRelative("strValue"); EditorGUI.PropertyField(propertyDrawRect, valueProperty); } else if (paramType == LuaParamType.UObject) { SerializedProperty gObjectProperty = property.FindPropertyRelative("gObject"); EditorGUI.PropertyField(propertyDrawRect, gObjectProperty); SerializedProperty uObjectProperty = property.FindPropertyRelative("uObject"); if (gObjectProperty.objectReferenceValue == null) { uObjectProperty.objectReferenceValue = null; } else { if (uObjectProperty.objectReferenceValue == null) { uObjectProperty.objectReferenceValue = gObjectProperty.objectReferenceValue; } EditorGUI.BeginDisabledGroup(true); { propertyDrawRect.y += propertyDrawRect.height; EditorGUI.PropertyField(propertyDrawRect, uObjectProperty); } EditorGUI.EndDisabledGroup(); List <string> names = new List <string>(); List <UnityObject> objects = new List <UnityObject>(); names.Add("GameObject"); objects.Add(gObjectProperty.objectReferenceValue); GameObject gObject = (GameObject)gObjectProperty.objectReferenceValue; Component[] gComponents = gObject.GetComponents <Component>(); foreach (var c in gComponents) { names.Add(c.GetType().Name); objects.Add(c); } propertyDrawRect.y += propertyDrawRect.height; uObjectProperty.objectReferenceValue = EGUI.DrawPopup <UnityObject>(propertyDrawRect, "Component", names.ToArray(), objects.ToArray(), uObjectProperty.objectReferenceValue); } } if (isArrayElement) { propertyDrawRect.y += propertyDrawRect.height; EGUI.DrawHorizontalLine(propertyDrawRect); } }