private void AddNewWidget(UEditorWidgetBase newControl) { //TODO: This functionality is already getting achieved by the onContainerChange() call, work out how to decom this //and still keep the select widget working. //Create a new hierarchy widget UEditorWidgetFoldout __newHierarchyWidget = UWidget.Create <UEditorWidgetFoldout>(); __newHierarchyWidget.BindTo(newControl, "Name"); __newHierarchyWidget.ObjectID = newControl.ObjectID; __newHierarchyWidget.LayoutMode = ePositioningLayout.Layout; //__newHierarchyWidget.OnClick += __newFoldout_OnClick; if (newControl.GetType().IsSubclassOf(typeof(UEditorPanelBase)) == false) { __newHierarchyWidget.BaseStyle = "label"; } Canvas.CurrentContainer.AddChild(newControl); UEditorWidgetFoldout __containerInHierarchy = (UEditorWidgetFoldout)UWidget.FindWidgetById(this.HierarchyContainer, Canvas.CurrentContainer.ObjectID); __newHierarchyWidget.IndentLevel = __containerInHierarchy.IndentLevel + 1; //Select the new control this.__newFoldout_OnClick(__newHierarchyWidget, new System.EventArgs()); }
private void EnableHierachyOnClick(List <UEditorWidgetBase> HierarchyList) { foreach (var item in HierarchyList) { UEditorWidgetFoldout __castFoldout = (UEditorWidgetFoldout)item; __castFoldout.OnClick += __newFoldout_OnClick; if (__castFoldout.Children.Count > 0) { EnableHierachyOnClick(__castFoldout.Children); } } }
public void BuildHericRecursive(UEditorWidgetFoldout ParentFoldout, List <UEditorWidgetBase> widgetList) { ParentFoldout.ClearChilden(); foreach (var item in widgetList) { UEditorWidgetFoldout __newFoldout = UWidget.Create <UEditorWidgetFoldout>(); __newFoldout.IndentLevel = ParentFoldout.IndentLevel + 1; __newFoldout.BindTo(item, "Name"); __newFoldout.LayoutMode = ePositioningLayout.Layout; __newFoldout.OnClick += __newFoldout_OnClick; //Set the widget ID to match the one on the canvas. //This little bit of hackery help us keep the desinger hierarchy and the toolbox layout in sync. __newFoldout.ObjectID = item.ObjectID; if (item.GetType().IsSubclassOf(typeof(UEditorPanelBase))) { ParentFoldout.AddChild(__newFoldout); UEditorPanelBase __castPanel = (UEditorPanelBase)item; __castPanel.onContainerChange += Hierarchy_onContainerChange; List <UEditorWidgetBase> __childList = new List <UEditorWidgetBase>(); foreach (var __childWidgets in __castPanel.Children) { if (item.GetType().IsSubclassOf(typeof(UEditorWidgetBase))) { UEditorWidgetBase __castChild = (UEditorWidgetBase)__childWidgets; __childList.Add(__castChild); } } BuildHericRecursive(__newFoldout, __childList); } else { __newFoldout.BaseStyle = "label"; ParentFoldout.AddChild(__newFoldout); } } }