private static EditorDataEntry GetEditorData(AGXUnity.IO.URDF.Element element, string name) { return(EditorData.Instance.GetData(element, name, entry => entry.Bool = false)); }
public static void DrawUrdfElement(AGXUnity.IO.URDF.Element element, int elementArrayIndex = -1) { if (element == null) { return; } var dropDownName = string.IsNullOrEmpty(element.Name) ? elementArrayIndex >= 0 ? $"{element.GetType().Name}[{elementArrayIndex}]" : element.GetType().Name : element.Name; if (!InspectorGUI.Foldout(GetEditorData(element, dropDownName), GUI.MakeLabel(InspectorGUISkin.Instance.TagTypename($"Urdf.{element.GetType().Name}") + ' ' + dropDownName))) { return; } using (InspectorGUI.IndentScope.Single) { var ignoreName = element is AGXUnity.IO.URDF.Inertial; if (!ignoreName) { var nameRect = EditorGUILayout.GetControlRect(); EditorGUI.PrefixLabel(nameRect, GUI.MakeLabel("Name"), InspectorEditor.Skin.Label); var orgXMax = nameRect.xMax; nameRect.x += EditorGUIUtility.labelWidth - 14.0f * InspectorGUI.IndentScope.Level; nameRect.xMax = orgXMax; EditorGUI.SelectableLabel(nameRect, element.Name, InspectorEditor.Skin.TextField); } if (element is AGXUnity.IO.URDF.Pose) { DrawUrdfPose(element as AGXUnity.IO.URDF.Pose); } else if (element is AGXUnity.IO.URDF.Material) { DrawUrdfMaterial(element as AGXUnity.IO.URDF.Material); return; } var properties = GetOrFindProperties(element.GetType()); var elementArg = new object[] { element }; var geometry = element as AGXUnity.IO.URDF.Geometry; foreach (var property in properties) { // Ignoring Unity specific properties such as "name" and "hideFlags". if (!char.IsUpper(property.Member.Name[0])) { continue; } if (!InspectorEditor.ShouldBeShownInInspector(property.Member)) { continue; } var containingType = property.GetContainingType(); if (containingType.IsArray) { if (typeof(AGXUnity.IO.URDF.Element).IsAssignableFrom(containingType.GetElementType())) { var array = property.Get <System.Collections.ICollection>(element); if (!InspectorGUI.Foldout(GetEditorData(element, property.Member.Name), InspectorGUI.MakeLabel(property.Member, $" [{array.Count}]"))) { continue; } using (InspectorGUI.IndentScope.Single) { var arrayIndex = 0; foreach (var arrayItem in array) { DrawUrdfElement(arrayItem as AGXUnity.IO.URDF.Element, arrayIndex++); } } } } else if (typeof(AGXUnity.IO.URDF.Element).IsAssignableFrom(containingType)) { DrawUrdfElement(property.Get <AGXUnity.IO.URDF.Element>(element), -1); } else if (geometry == null || IsValidGeometryProperty(geometry, property)) { var drawerMethod = GetDrawerMethod(containingType); drawerMethod.Drawer?.Invoke(null, new object[] { elementArg, property }); } } } }