// Creates controller, view and view model for a blackboard item and adds the view to the specified index in the category
        // By default adds it to the end of the list if no insertionIndex specified
        internal SGBlackboardRow InsertBlackboardRow(BlackboardItem shaderInput, int insertionIndex = -1)
        {
            var shaderInputViewModel = new ShaderInputViewModel()
            {
                model      = shaderInput,
                parentView = blackboardCategoryView,
            };
            var blackboardItemController = new BlackboardItemController(shaderInput, shaderInputViewModel, DataStore);

            m_BlackboardItemControllers.TryGetValue(shaderInput.objectId, out var existingItemController);
            if (existingItemController == null)
            {
                m_BlackboardItemControllers.Add(shaderInput.objectId, blackboardItemController);
                // If no index specified, add to end of category
                if (insertionIndex == -1)
                {
                    blackboardCategoryView.Add(blackboardItemController.BlackboardItemView);
                }
                else
                {
                    blackboardCategoryView.Insert(insertionIndex, blackboardItemController.BlackboardItemView);
                }

                blackboardCategoryView.MarkDirtyRepaint();

                return(blackboardItemController.BlackboardItemView);
            }
            else
            {
                AssertHelpers.Fail("Tried to add blackboard item that already exists to category.");
                return(null);
            }
        }
 internal void RemoveBlackboardRow(BlackboardItem shaderInput)
 {
     m_BlackboardItemControllers.TryGetValue(shaderInput.objectId, out var associatedBlackboardItemController);
     if (associatedBlackboardItemController != null)
     {
         associatedBlackboardItemController.Destroy();
         m_BlackboardItemControllers.Remove(shaderInput.objectId);
     }
     else
     {
         AssertHelpers.Fail("Failed to find associated blackboard item controller for shader input that was just deleted. Cannot clean up view associated with input.");
     }
 }
Example #3
0
        internal void RemoveBlackboardRow(BlackboardItem shaderInput)
        {
            BlackboardItemController associatedBlackboardItemController = null;

            m_BlackboardItemControllers.TryGetValue(shaderInput.guid, out associatedBlackboardItemController);

            if (associatedBlackboardItemController != null)
            {
                associatedBlackboardItemController.BlackboardItemView.RemoveFromHierarchy();
                m_BlackboardItemControllers.Remove(shaderInput.guid);
            }
            else
            {
                Debug.Log("ERROR: Failed to find associated blackboard item controller for shader input that was just deleted. Cannot clean up view associated with input.");
            }
        }
Example #4
0
        // Creates controller, view and view model for a blackboard item and adds the view to the specified index in the section
        // By default adds it to the end of the list if no insertionIndex specified
        internal SGBlackboardRow InsertBlackboardRow(BlackboardItem shaderInput, int insertionIndex = -1)
        {
            // If no index specified, add to end of section
            if (insertionIndex == -1)
            {
                insertionIndex = m_BlackboardItemControllers.Count;
            }

            var shaderInputViewModel = new ShaderInputViewModel()
            {
                model      = shaderInput,
                parentView = BlackboardSectionView,
            };
            var blackboardItemController = new BlackboardItemController(shaderInput, shaderInputViewModel, DataStore);

            m_BlackboardItemControllers.Add(shaderInput.guid, blackboardItemController);

            BlackboardSectionView.Insert(insertionIndex, blackboardItemController.BlackboardItemView);

            return(blackboardItemController.BlackboardItemView);
        }