Exemplo n.º 1
0
        internal static Bounds CalculateSelectionBoundsInSpace(Vector3 position, Quaternion rotation, bool rectBlueprintMode)
        {
            Quaternion rotation2 = Quaternion.Inverse(rotation);
            Vector3    vector    = new Vector3(3.40282347E+38f, 3.40282347E+38f, 3.40282347E+38f);
            Vector3    vector2   = new Vector3(-3.40282347E+38f, -3.40282347E+38f, -3.40282347E+38f);

            Vector3[]    array       = new Vector3[2];
            GameObject[] gameObjects = Selection.gameObjects;
            for (int i = 0; i < gameObjects.Length; i++)
            {
                GameObject gameObject  = gameObjects[i];
                Bounds     localBounds = InternalEditorUtility.GetLocalBounds(gameObject);
                array[0] = localBounds.min;
                array[1] = localBounds.max;
                for (int j = 0; j < 2; j++)
                {
                    for (int k = 0; k < 2; k++)
                    {
                        for (int l = 0; l < 2; l++)
                        {
                            Vector3 vector3 = new Vector3(array[j].x, array[k].y, array[l].z);
                            if (rectBlueprintMode && InternalEditorUtility.SupportsRectLayout(gameObject.transform))
                            {
                                Vector3 localPosition = gameObject.transform.localPosition;
                                localPosition.z = 0f;
                                vector3         = gameObject.transform.parent.TransformPoint(vector3 + localPosition);
                            }
                            else
                            {
                                vector3 = gameObject.transform.TransformPoint(vector3);
                            }
                            vector3 = rotation2 * (vector3 - position);
                            for (int m = 0; m < 3; m++)
                            {
                                vector[m]  = Mathf.Min(vector[m], vector3[m]);
                                vector2[m] = Mathf.Max(vector2[m], vector3[m]);
                            }
                        }
                    }
                }
            }
            return(new Bounds((vector + vector2) * 0.5f, vector2 - vector));
        }