Exemplo n.º 1
0
 static void OnEditTextRequested(Experimental.GraphView.Blackboard blackboard, VisualElement blackboardField, string newName)
 {
     if (blackboardField is BlackboardVariableField field)
     {
         field.Store.Dispatch(new RenameElementAction((IRenamableModel)field.GraphElementModel, newName));
         field.UpdateTitleFromModel();
     }
 }
Exemplo n.º 2
0
        void OnMoveItemRequested(Experimental.GraphView.Blackboard blackboard, int index, VisualElement field)
        {
            // TODO: Workaround to prevent moving item above a BlackboardThisField, as all check code is executed
            // within UnityEditor.Experimental.GraphView.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);
        }
Exemplo n.º 3
0
// 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(Experimental.GraphView.Blackboard blackboard)
        {
            var currentGraphModel = Store.GetState().CurrentGraphModel;

            currentGraphModel.Stencil.GetBlackboardProvider().AddItemRequested(Store, (IAction)null);
        }