FairyGUI.RelationItem.InternalAdd C# (CSharp) Method

InternalAdd() public method

public InternalAdd ( RelationType relationType, bool usePercent ) : void
relationType RelationType
usePercent bool
return void
        public void InternalAdd(RelationType relationType, bool usePercent)
        {
            if (relationType == RelationType.Size)
            {
                InternalAdd(RelationType.Width, usePercent);
                InternalAdd(RelationType.Height, usePercent);
                return;
            }

            RelationDef info = new RelationDef();
            info.percent = usePercent;
            info.type = relationType;
            _defs.Add(info);

            //当使用中线关联时,因为需要除以2,很容易因为奇数宽度/高度造成小数点坐标;当使用百分比时,也会造成小数坐标;
            //所以设置了这类关联的对象,自动启用pixelSnapping
            if (usePercent || relationType == RelationType.Left_Center || relationType == RelationType.Center_Center || relationType == RelationType.Right_Center
                    || relationType == RelationType.Top_Middle || relationType == RelationType.Middle_Middle || relationType == RelationType.Bottom_Middle)
                _owner.pixelSnapping = true;
        }

Usage Example

Example #1
0
        public void Setup(ByteBuffer buffer, bool parentToChild)
        {
            int     cnt = buffer.ReadByte();
            GObject target;

            for (int i = 0; i < cnt; i++)
            {
                int targetIndex = buffer.ReadShort();
                if (targetIndex == -1)
                {
                    target = _owner.parent;
                }
                else if (parentToChild)
                {
                    target = ((GComponent)_owner).GetChildAt(targetIndex);
                }
                else
                {
                    target = _owner.parent.GetChildAt(targetIndex);
                }

                RelationItem newItem = new RelationItem(_owner);
                newItem.target = target;
                _items.Add(newItem);

                int cnt2 = buffer.ReadByte();
                for (int j = 0; j < cnt2; j++)
                {
                    RelationType rt         = (RelationType)buffer.ReadByte();
                    bool         usePercent = buffer.ReadBool();
                    newItem.InternalAdd(rt, usePercent);
                }
            }
        }
All Usage Examples Of FairyGUI.RelationItem::InternalAdd