Пример #1
0
        Bounds GetBounds()
        {
            if (ISOTarget == null || ISOTarget.Length == 0)
            {
                return(new Bounds(transform.position, Vector3.zero));
            }

            if (ISOTarget.Any(r => r is RegularCollider))
            {
                return(ISOTarget.First(r => r is RegularCollider).GetBounds());
            }

            var boundsArray = GetComponents <Collider>().Where(r => !r.isTrigger).Select(r => r.bounds).ToArray();

            if (boundsArray == null || boundsArray.Length == 0)
            {
                boundsArray = ISOTarget.Select(r => r.GetBounds()).ToArray();
            }

            Bounds bounds = boundsArray[0];

            for (int i = 1; i < boundsArray.Length; ++i)
            {
                bounds.Encapsulate(boundsArray[i]);
            }

            return(bounds);
        }
Пример #2
0
        Collider GetCollider()
        {
            if (ISOTarget != null && ISOTarget.Length > 0)
            {
                if (ISOTarget.Any(r => r is RegularCollider))
                {
                    return((ISOTarget.First(r => r is RegularCollider) as RegularCollider).BC);
                }
            }

            Collider _col = GetComponent <Collider>();

            if (_col != null)
            {
                return(_col);
            }

            return(null);
        }