// 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);
            }
        }
Ejemplo n.º 2
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);
        }