FairyGUI.DisplayObject.EnterPaintingMode C# (CSharp) Method

EnterPaintingMode() public method

进入绘画模式,整个对象将画到一张RenderTexture上,然后这种贴图将代替原有的显示内容。 可以在onPaint回调里对这张纹理进行进一步操作,实现特殊效果。 可能有多个地方要求进入绘画模式,这里用requestorId加以区别,取值是1、2、4、8、16以此类推。1024内内部保留。用户自定义的id从1024开始。
public EnterPaintingMode ( int requestorId, Margin margin ) : void
requestorId int
margin Margin 纹理四周的留空。如果特殊处理后的内容大于原内容,那么这里的设置可以使纹理扩大。
return void
        public void EnterPaintingMode(int requestorId, Margin? margin)
        {
            bool first = _paintingMode == 0;
            _paintingMode |= requestorId;
            if (first)
            {
                if (paintingGraphics == null)
                {
                    if (graphics == null)
                        paintingGraphics = new NGraphics(this.gameObject);
                    else
                    {
                        GameObject go = new GameObject(this.gameObject.name + " (Painter)");
                        go.layer = this.gameObject.layer;
                        ToolSet.SetParent(go.transform, cachedTransform);
                        go.hideFlags = DisplayOptions.hideFlags;
                        paintingGraphics = new NGraphics(go);
                    }
                }
                else
                    paintingGraphics.enabled = true;
                paintingGraphics.vertexMatrix = null;

                if (this is Container)
                {
                    ((Container)this).SetChildrenLayer(CaptureCamera.hiddenLayer);
                    ((Container)this).UpdateBatchingFlags();
                }
                else
                    this.InvalidateBatchingState();

                if (graphics != null)
                    this.gameObject.layer = CaptureCamera.hiddenLayer;

                _paintingMargin = new Margin();
            }
            if (margin != null)
                _paintingMargin = (Margin)margin;
            _paintingFlag = 1;
        }

Usage Example

 static public int EnterPaintingMode(IntPtr l)
 {
     try {
         FairyGUI.DisplayObject self = (FairyGUI.DisplayObject)checkSelf(l);
         System.Int32           a1;
         checkType(l, 2, out a1);
         System.Nullable <FairyGUI.Margin> a2;
         checkNullable(l, 3, out a2);
         self.EnterPaintingMode(a1, a2);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }