EditorObjects.Visualization.HierarchyNode.AddToLayer C# (CSharp) Method

AddToLayer() public method

public AddToLayer ( Layer layer ) : void
layer Layer
return void
        public void AddToLayer(Layer layer)
        {
            mLayer = layer;
            if (layer != null)
            {
                if (layer.CameraBelongingTo == null)
                {
                    mText.CameraToAdjustPixelPerfectTo = SpriteManager.Camera;
                }
                else
                {
                    mText.CameraToAdjustPixelPerfectTo = layer.CameraBelongingTo;
                }
            }

            if (mCircleVisibleRepresentation != null)
            {
                ShapeManager.AddToLayer(mCircleVisibleRepresentation, layer);
            }
            else
            {
                SpriteManager.AddToLayer(mSpriteVisibleRepresentation, layer);

            }
            ShapeManager.AddToLayer(mParentLine, layer);
            ShapeManager.AddToLayer(mParentAttachmentPoint, layer);
            TextManager.AddToLayer(mText, layer);
            mText.SetPixelPerfectScale(mLayer);
        }

Usage Example

        public void UpdateToList()
        {
            bool hasAnythingChanged = false;

            #region If there is no list watching, then return
            if (mListOfAttachables == null)
            {
                return;
            }
            #endregion

            #region Add nodes to the dictionary if there are any in the list that aren't in the dictionary

            for (int i = 0; i < mListOfAttachables.Count; i++)
            {
                IAttachable iAttachable = (IAttachable)mListOfAttachables[i];

                if (iAttachable == null)
                {
                    throw new Exception();
                }

                if (!IsNodeCreatedForAttachable(iAttachable))
                {
                    HierarchyNode hierarchyNode = new HierarchyNode(VisibleRepresentationType.Sprite);

                    hierarchyNode.TextRed   = mTextColor.R;
                    hierarchyNode.TextGreen = mTextColor.G;
                    hierarchyNode.TextBlue  = mTextColor.B;

                    if (LayerUsing != null)
                    {
                        hierarchyNode.AddToLayer(LayerUsing);
                    }

                    mNodes.Add(iAttachable, hierarchyNode);

                    hierarchyNode.ObjectRepresenting = iAttachable;
                    mNodesAsList.Add(hierarchyNode);

                    hasAnythingChanged = true;
                }
            }

            #endregion

            #region Remove nodes if necessary

            if (mListOfAttachables.Count < this.mNodesAsList.Count)
            {
                for (int i = 0; i < mNodesAsList.Count; i++)
                {
                    HierarchyNode node = mNodesAsList[i];

                    if (!this.mListOfAttachables.Contains(node.ObjectRepresenting))
                    {
                        // Remove this node
                        mNodes.Remove(node.ObjectRepresenting);
                        node.Destroy();

                        hasAnythingChanged = true;
                    }
                }
                //There are nodes in the dictionary that have to be removed
            }

            #endregion

            #region Update the element visibility of each node

            foreach (HierarchyNode node in mNodesAsList)
            {
                HierarchyNode parentNode = null;

                IAttachable nodeParent = GetParent(node.ObjectRepresenting);

                if (nodeParent != null)
                {
                    parentNode = GetNodeFromAttachable(nodeParent);
                }

                hasAnythingChanged |= node.UpdateElementVisibility(parentNode);
            }

            #endregion

            if (hasAnythingChanged)
            {
                AutoPosition();
            }
        }
All Usage Examples Of EditorObjects.Visualization.HierarchyNode::AddToLayer