private void OnGUI() { DrawSizeAnalysis(); _serializedObject.Update(); // Iterate through serialized properties and draw them like the Inspector (But with ports) SerializedProperty componentProperty = _serializedObject.FindProperty(nameof(_componentDefinition)); // Directory EditorGUILayout.BeginHorizontal(); var directoryProperty = componentProperty.FindPropertyRelative("Directory"); GUIDrawers.DrawFieldWithLabel(directoryProperty); if (GUILayout.Button("\u27b1", GUILayout.Width(30))) { var dialogPath = EditorUtility.OpenFolderPanel("Code directory", "", ""); if (!string.IsNullOrWhiteSpace(dialogPath)) { directoryProperty.stringValue = PathExtension.AssetsPath(dialogPath); } } EditorGUILayout.EndHorizontal(); // Namespace var namespaceProperty = componentProperty.FindPropertyRelative("Namespace"); using (new GUIEnabledScope(false)) { if (!namespaceProperty.stringValue.EndsWith(".Components", StringComparison.InvariantCultureIgnoreCase)) { EditorGUILayout.TextArea("Remember, if namespace do not ends with \".Components\" system will automatically add it", EditorStyles.helpBox); } } EditorGUILayout.BeginHorizontal(); GUIDrawers.DrawFieldWithLabel(namespaceProperty); var selectedNamespace = DrawNamespacesPopup(namespaceProperty.stringValue); if (!string.IsNullOrWhiteSpace(selectedNamespace)) { namespaceProperty.stringValue = selectedNamespace; } EditorGUILayout.EndHorizontal(); // Type & Name EditorGUILayout.BeginHorizontal(); GUIDrawers.DrawFieldWithLabel(componentProperty.FindPropertyRelative("ComponentType")); GUIDrawers.DrawFieldWithLabel(componentProperty.FindPropertyRelative("ComponentName")); EditorGUILayout.EndHorizontal(); // Fields GUIDrawers.DrawArray <object>(componentProperty.FindPropertyRelative("Fields")); _serializedObject.ApplyModifiedProperties(); DrawActionButtons(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { PropertyRect propertyRect = new PropertyRect(position); EditorGUI.BeginProperty(position, label, property); GUIDrawers.DrawFieldWithLabelPercentage(ref propertyRect, property.FindPropertyRelative(nameof(ComponentField.accessType)), labelWidth: 100, labelWidthPercentage: 0.3f); propertyRect.AllocateWidthPrecent(0.05f); GUIDrawers.DrawFieldWithLabelPercentage(ref propertyRect, property.FindPropertyRelative(nameof(ComponentField.type)), false, labelWidth: 50, labelWidthPercentage: 0.65f); GUIDrawers.DrawFieldWithLabel(ref propertyRect, property.FindPropertyRelative(nameof(ComponentField.name)), labelWidth: 100); EditorGUI.EndProperty(); }