static void OnEditTextRequested(Unity.GraphElements.Blackboard blackboard, VisualElement blackboardField, string newName) { if (blackboardField is BlackboardVariableField field) { field.Store.Dispatch(new RenameElementAction((IRenamableModel)field.GraphElementModel, newName)); field.UpdateTitleFromModel(); } }
void OnMoveItemRequested(Unity.GraphElements.Blackboard blackboard, int index, VisualElement field) { // TODO: Workaround to prevent moving item above a BlackboardThisField, as all check code is executed // within Unity.GraphElements.BlackboardSection in private or internal functions bool hasBlackboardThisField = (blackboard as Blackboard)?.Sections ? [0]?.Children() ?.Any(x => x is BlackboardThisField) ?? false; if (index == 0 && hasBlackboardThisField) { return; } var currentGraphModel = Store.GetState().CurrentGraphModel; currentGraphModel.Stencil.GetBlackboardProvider().MoveItemRequested(Store, index, field); }
// TODO: Enable when GraphView supports it // void UpdateProperties(PersistedProperties properties) // { // var newPosition = properties.position; // var newSize = properties.size; // var newAutoDimOpacityEnabled = properties.isAutoDimOpacityEnabled; // // float validateFloat = newPosition.x + newPosition.y + newPosition.z + newSize.x + newSize.y; // if (float.IsInfinity(validateFloat) || float.IsNaN(validateFloat) || newSize.x < float.Epsilon || newSize.y < float.Epsilon) // return; // // SetPosition(new Rect(newPosition, newSize)); // // if ((this.IsAutoDimOpacityEnabled() && !newAutoDimOpacityEnabled) || // (!this.IsAutoDimOpacityEnabled() && newAutoDimOpacityEnabled)) // this.ToggleAutoDimOpacity(VisualElementExtensions.StartingOpacity.Min); // // UpdatePersistedProperties(newPosition, newSize, newAutoDimOpacityEnabled); // } void OnAddItemRequested(Unity.GraphElements.Blackboard blackboard) { var currentGraphModel = Store.GetState().CurrentGraphModel; currentGraphModel.Stencil.GetBlackboardProvider().AddItemRequested(Store, (IAction)null); }