public List <ObjectNode> BuildSelectableObjectsList(IEnumerable <InterfaceableContainerPropertyDrawer.SelectableObject> selectableObjects, Object selectedObject, out bool selectingProjectAssets) { selectingProjectAssets = false; _rootNodes = new List <ObjectNode>(); _parentNodes = new Dictionary <Object, ObjectNode>(); foreach (var selectableObject in selectableObjects) { if (selectedObject == selectableObject.Object) { selectingProjectAssets = selectableObject.IsProjectAsset; } var selectableObjectNode = new ObjectNode { Object = selectableObject.Object, NodeName = InterfaceableGUIHelper.GetObjectName(selectableObject.Object), IsSelectable = true, IsPingable = !selectableObject.IsComponent && InterfaceableGUIHelper.IsPingable(selectableObject.Object), IsProjectAsset = selectableObject.IsProjectAsset, }; if (selectableObject.IsComponent) { selectableObjectNode.Parent = GetOrCreateParentNode(selectableObjectNode); } else { _rootNodes.Add(selectableObjectNode); } } var missingParents = _parentNodes.Values.Where(n => n.Parent == null && !_rootNodes.Contains(n)).ToList(); _rootNodes.AddRange(missingParents); var @return = SortedNodes(_rootNodes); _parentNodes.Clear(); _rootNodes.Clear(); return(@return); }
private ObjectNode GetOrCreateParentNode(ObjectNode childNode) { GameObject parent = null; var component = childNode.Object as Component; if (component != null) { parent = component.gameObject; } else { var gameobject = childNode.Object as GameObject; if (gameobject != null && gameobject.transform.parent != null) { parent = gameobject.transform.parent.gameObject; } } if (parent != null) { ObjectNode parentNode; if (!_parentNodes.TryGetValue(parent, out parentNode)) { parentNode = new ObjectNode { Object = parent, IsSelectable = false, IsPingable = InterfaceableGUIHelper.IsPingable(parent), IsProjectAsset = InterfaceableGUIHelper.IsProjectAsset(parent), NodeName = InterfaceableGUIHelper.GetObjectName(parent) }; _parentNodes.Add(parent, parentNode); parentNode.Parent = GetOrCreateParentNode(parentNode); } parentNode.Children.Add(childNode); return(parentNode); } return(null); }
private static string BuildEditorResultString(string resultType, Object @object) { if (@object != null) { var component = @object as Component; if (component != null) { return($"{component.gameObject.name} ( {NeverLab.Interfaceable.InterfaceableContainerBase.ConstructResolvedName(@object.GetType())} )"); } return(InterfaceableGUIHelper.GetObjectName(@object)); } if (!string.IsNullOrEmpty(resultType)) { return(resultType); } return(null); }