public ChoseShapeDataField(ShapeDataFactory shapeDataFactory, CanDependOnShapeBlueprint dependent, string fieldName, Func <TShapeData> getShapeDataFunc, Action <TShapeData> setShapeDataFunc) { m_DataFactory = shapeDataFactory; m_Dependent = dependent; m_FieldName = fieldName; m_GetShapeDataFunc = getShapeDataFunc; m_SetShapeDataFunc = setShapeDataFunc; VisualElement firstRow = new VisualElement { style = { flexDirection = FlexDirection.Row } }; firstRow.Add(m_Label = new Label()); m_ToolbarMenu = new ToolbarMenu { text = "Change", style = { flexDirection = FlexDirection.Row } }; m_ToolbarMenu.RemoveFromClassList("unity-toolbar-menu"); m_ToolbarMenu.AddToClassList("unity-button"); firstRow.Add(m_ToolbarMenu); Add(firstRow); IValidator pointNotEmptyValidator = new DataNotEmptyValidator <TShapeData>(getShapeDataFunc, action => m_UpdateValidatorAction = action); VisualElement validatorField = new ValidatorField(pointNotEmptyValidator); Add(validatorField); m_DataFactory.BecameDirty.Subscribe(BecameDirty); m_AutoSaveScheduler = schedule.Execute(Update); m_AutoSaveScheduler.Every(200); UpdateList(); UpdateName(); m_UpdateValidatorAction?.Invoke(); }
private VisualElement GetCreateShapeActionVisualElement() { ToolbarMenu shapeActionTypesList = new ToolbarMenu { text = "Add Action", style = { flexDirection = FlexDirection.Row } }; shapeActionTypesList.RemoveFromClassList("unity-toolbar-menu"); shapeActionTypesList.AddToClassList("unity-button"); shapeActionTypesList.AddToClassList("create"); foreach (ShapeActionFactory.ShapeActionType actionType in Enum .GetValues(typeof(ShapeActionFactory.ShapeActionType)) .Cast <ShapeActionFactory.ShapeActionType>()) { shapeActionTypesList.menu.AppendAction( actionType.ToString(), menuAction => AddShapeAction(actionType), DropdownMenuAction.AlwaysEnabled); } return(shapeActionTypesList); }
private VisualElement GetBottomVisualElement() { VisualElement visualElement = new VisualElement(); if (m_ShapeBlueprintFactory == null) { return(visualElement); } ToolbarMenu blueprintsList = new ToolbarMenu { text = "Create new Blueprint", style = { flexDirection = FlexDirection.Row } }; blueprintsList.RemoveFromClassList("unity-toolbar-menu"); blueprintsList.AddToClassList("unity-button"); blueprintsList.AddToClassList("create"); CreateDropdown(blueprintsList.menu); visualElement.Add(blueprintsList); return(visualElement); }