protected override ObjectValue[] GetChildrenSafe(ObjectPath path, int index, int count, IEvaluationOptions options) { // Call gameObject.GetComponents(typeof(Component)) var componentType = GetType("UnityEngine.Component"); var typeofComponent = Adaptor.CreateTypeObject(Context, componentType); var componentsArray = InvokeInstanceMethod(myGameObject, "GetComponents", typeofComponent) as ArrayMirror; if (componentsArray == null) { ourLogger.Warn("UnityEngine.Component.GetComponents did not return an instance of ArrayMirror"); return(EmptyArray <ObjectValue> .Instance); } // Component name comes from ObjectNames.GetInspectorTitle(component) var objectNamesType = GetType("UnityEditor.ObjectNames"); var objectValues = new List <ObjectValue>(componentsArray.Length); foreach (var componentValue in componentsArray.GetValues(0, componentsArray.Length)) { try { var name = GetComponentName(objectNamesType, componentValue); objectValues.Add(CreateObjectValue(name, componentValue, options)); } catch (Exception e) { ourLogger.Error(e, "Failed to fetch component {0} of GameObject {1}", componentValue, myGameObject); } } return(objectValues.ToArray()); }