Esempio n. 1
0
        void OnValidate()
        {
            bMode = boundsMode;
            if (model)
            {
                transform.rotation = model.transform.rotation;

                Bounds bounds = GetBounds(model);
                Debug.Log(bounds.ToString());

                CappedSectionCorner csc = GetComponent <CappedSectionCorner>();
                if (csc)
                {
                    csc.Size(bounds);
                }
                CappedSectionBox csb = GetComponent <CappedSectionBox>();
                if (csb)
                {
                    csb.Size(bounds);
                }
                Planar_xyzClippingSection pcs = GetComponent <Planar_xyzClippingSection>();
                if (pcs)
                {
                    pcs.Size(bounds);
                }
            }
        }
Esempio n. 2
0
    Vector3? _MaintainBounds(BoundsMode vertical, BoundsMode horizontal, Vector3 pos)
    {
        screen = c.WorldToScreenPoint(pos);
        if (InBounds(screen, false))
            return null;

        update = false;
        if (horizontal == BoundsMode.Clamp)
        {
            if (screen.x <= 1f)
            {
                screen.x = 0f;
                update = true;
            }
            else if (screen.x >= pixelRect.width)
            {
                screen.x = pixelRect.width;
                update = true;
            }
        }
        else if (horizontal == BoundsMode.Wrap)
        {
            if (screen.x <= 0f)
            {
                screen.x = pixelRect.width;
                update = true;
            }
            else if (screen.x >= pixelRect.width)
            {
                screen.x = 0f;
                update = true;
            }
        }

        if (vertical == BoundsMode.Clamp)
        {
            if (screen.y <= 0)
            {
                screen.y = 0;
                update = true;
            }
            else if (screen.y >= pixelRect.height)
            {
                screen.y = pixelRect.height;
                update = true;
            }
        }
        else if (vertical == BoundsMode.Wrap)
        {
            if (screen.y <= 0)
            {
                screen.y = pixelRect.height;
                update = true;
            }
            else if (screen.y >= pixelRect.height)
            {
                screen.y = 0;
                update = true;
            }
        }

        if (update)
        {
            pos = c.ScreenToWorldPoint(screen);
        }

        return pos;
    }
Esempio n. 3
0
 public static Vector3? MaintainBounds(BoundsMode vertical, BoundsMode horizontal, Vector3 pos)
 {
     return _instance._MaintainBounds(vertical,horizontal,pos);
 }