Example #1
0
    // Update is called once per frame
    new protected void Update()
    {
        base.Update();
        if (OT.isValid && !isInvalid && Application.isPlaying)
        {
            if (_clipLayer != clipLayer_)
            {
                clipLayer_ = clipLayer;
                if (clipped)
                {
                    OT.UnClip(gameObject);
                    lastRect = worldRect;
                }
                clipped = false;
            }

            if (!clipped && clipLayer > 0)
            {
                Rect clipRect = worldRect;
                clipRect.xMin   += clipMargin;
                clipRect.yMin   += clipMargin;
                clipRect.width  -= clipMargin;
                clipRect.height -= clipMargin;

                GameObject[] excludes = new GameObject[] { };
                if (clipMargin > 0)
                {
                    excludes = new GameObject[] { gameObject }
                }
                ;

                _clipCamera = OT.Clip(clipRect, gameObject, clipLayer, excludes);
                baseVector  = clipCamera.transform.position;
                clipped     = true;

                lastRect     = worldRect;
                lastClipRect = clipRect;
            }
            else
            if (clipped)
            {
                if (!worldRect.Equals(lastRect))
                {
                    Rect clipRect = worldRect;
                    clipRect.xMin   += clipMargin;
                    clipRect.yMin   += clipMargin;
                    clipRect.width  -= clipMargin;
                    clipRect.height -= clipMargin;
                    OT.ClipMove(gameObject, clipRect);
                    baseVector = _clipCamera.transform.position;
                    lastRect   = worldRect;
                    clipCamera.transform.Translate(offset);
                }
            }
        }
    }
}