Beispiel #1
0
        /// <summary>
        /// Convenience function that returns the sides the anchored point is anchored to.
        /// </summary>

        public Vector3[] GetSides(Transform relativeTo, EnumSideType sideType = EnumSideType.AdaptTwoSide)
        {
            if (target != null)
            {
                if (rect != null)
                {
                    return(rect.GetSides(relativeTo, sideType));
                }
#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6
                if (target.camera != null)
                {
                    return(target.camera.GetSides(relativeTo));
                }
#else
                if (target.GetComponent <Camera>() != null)
                {
                    return(target.GetComponent <Camera>().GetSides(relativeTo));
                }
#endif
            }
            return(null);
        }
Beispiel #2
0
    /// <summary>
    /// Get the sides of the rectangle relative to the specified transform.
    /// The order is left, top, right, bottom.
    /// </summary>

    public virtual Vector3[] GetSides(Transform relativeTo, EnumSideType sideType = EnumSideType.AdaptTwoSide)
    {
        if (anchorCamera != null)
        {
            return(mCam.GetSides(cameraRayDistance, relativeTo, sideType));
        }

        Vector3 pos = cachedTransform.position;

        for (int i = 0; i < 4; ++i)
        {
            mSides[i] = pos;
        }

        if (relativeTo != null)
        {
            for (int i = 0; i < 4; ++i)
            {
                mSides[i] = relativeTo.InverseTransformPoint(mSides[i]);
            }
        }
        return(mSides);
    }