ContainsStatic() статический приватный Метод

static private ContainsStatic ( GameObject objects ) : bool
objects UnityEngine.GameObject
Результат bool
Пример #1
0
        public override void OnToolGUI(EditorWindow window)
        {
            var view = window as SceneView;

            if (!view || !Selection.activeTransform || Tools.s_Hidden)
            {
                return;
            }

            if (!StageUtility.IsGameObjectRenderedByCamera(Selection.activeTransform.gameObject, Camera.current))
            {
                return;
            }

            bool isStatic = (!Tools.s_Hidden && EditorApplication.isPlaying && GameObjectUtility.ContainsStatic(Selection.gameObjects));

            using (new EditorGUI.DisabledScope(isStatic))
            {
                Vector3 handlePosition = Tools.handlePosition;

                ToolGUI(view, handlePosition, isStatic);

                Handles.ShowStaticLabelIfNeeded(handlePosition);
            }
        }
Пример #2
0
 protected virtual void OnToolGUI(SceneView view)
 {
     if ((Selection.activeTransform != null) && !Tools.s_Hidden)
     {
         bool disabled = (!Tools.s_Hidden && EditorApplication.isPlaying) && GameObjectUtility.ContainsStatic(Selection.gameObjects);
         EditorGUI.BeginDisabledGroup(disabled);
         Vector3 handlePosition = Tools.handlePosition;
         this.ToolGUI(view, handlePosition, disabled);
         Handles.ShowStaticLabelIfNeeded(handlePosition);
         EditorGUI.EndDisabledGroup();
     }
 }
Пример #3
0
 protected virtual void OnToolGUI(SceneView view)
 {
     if (Selection.activeTransform && !Tools.s_Hidden)
     {
         bool flag = !Tools.s_Hidden && EditorApplication.isPlaying && GameObjectUtility.ContainsStatic(Selection.gameObjects);
         using (new EditorGUI.DisabledScope(flag))
         {
             Vector3 handlePosition = Tools.handlePosition;
             this.ToolGUI(view, handlePosition, flag);
             Handles.ShowStaticLabelIfNeeded(handlePosition);
         }
     }
 }
Пример #4
0
        protected virtual void OnToolGUI(SceneView view)
        {
            if (!Selection.activeTransform || Tools.s_Hidden)
            {
                return;
            }
            bool flag = !Tools.s_Hidden && EditorApplication.isPlaying && GameObjectUtility.ContainsStatic(Selection.gameObjects);

            EditorGUI.BeginDisabledGroup(flag);
            Vector3 handlePosition = Tools.handlePosition;

            this.ToolGUI(view, handlePosition, flag);
            Handles.ShowStaticLabelIfNeeded(handlePosition);
            EditorGUI.EndDisabledGroup();
        }
Пример #5
0
        protected virtual void OnToolGUI(SceneView view)
        {
            if (!Selection.activeTransform || Tools.s_Hidden)
            {
                return;
            }

            bool isStatic = (!Tools.s_Hidden && EditorApplication.isPlaying && GameObjectUtility.ContainsStatic(Selection.gameObjects));

            using (new EditorGUI.DisabledScope(isStatic))
            {
                Vector3 handlePosition = Tools.handlePosition;

                ToolGUI(view, handlePosition, isStatic);

                Handles.ShowStaticLabelIfNeeded(handlePosition);
            }
        }
Пример #6
0
        internal static Quaternion DoRotationHandle(RotationHandleIds ids, Quaternion rotation, Vector3 position, RotationHandleParam param)
        {
            var evt        = Event.current;
            var camForward = Handles.inverseMatrix.MultiplyVector(Camera.current != null ? Camera.current.transform.forward : Vector3.forward);

            var size     = HandleUtility.GetHandleSize(position);
            var temp     = color;
            var isStatic = (!Tools.s_Hidden && EditorApplication.isPlaying && GameObjectUtility.ContainsStatic(Selection.gameObjects));

            var isHot = ids.Has(GUIUtility.hotControl);

            // Draw freerotation first to give it the lowest priority
            if (!isStatic &&
                param.ShouldShow(RotationHandleParam.Handle.XYZ) &&
                (isHot && ids.xyz == GUIUtility.hotControl || !isHot))
            {
                color    = centerColor;
                rotation = UnityEditorInternal.FreeRotate.Do(ids.xyz, rotation, position, size * param.xyzSize, param.displayXYZCircle);
            }

            var radiusOfAxesHandles = -1f;

            for (var i = 0; i < 3; ++i)
            {
                if (!param.ShouldShow(i))
                {
                    continue;
                }

                var axisColor = GetColorByAxis(i);
                color = isStatic ? Color.Lerp(axisColor, staticColor, staticBlend) : axisColor;
                color = ToActiveColorSpace(color);
                var axisDir = GetAxisVector(i);

                var radius = size * param.axisSize[i];
                radiusOfAxesHandles = Mathf.Max(radius, radiusOfAxesHandles);

                rotation = UnityEditorInternal.Disc.Do(ids[i], rotation, position, rotation * axisDir, radius, true, SnapSettings.rotation, param.enableRayDrag, true, k_RotationPieColor);
            }

            if (radiusOfAxesHandles > 0 && evt.type == EventType.Repaint)
            {
                Handles.color = new Color(0, 0, 0, 0.2f);
                Handles.DrawWireDisc(position, camForward, radiusOfAxesHandles);
            }

            if (isHot && evt.type == EventType.Repaint)
            {
                color = ToActiveColorSpace(s_DisabledHandleColor);
                Handles.DrawWireDisc(position, camForward, size * param.axisSize[0]);
            }

            if (!isStatic &&
                param.ShouldShow(RotationHandleParam.Handle.CameraAxis) &&
                (isHot && ids.cameraAxis == GUIUtility.hotControl || !isHot))
            {
                color    = ToActiveColorSpace(centerColor);
                rotation = UnityEditorInternal.Disc.Do(ids.cameraAxis, rotation, position, camForward, size * param.cameraAxisSize, false, 0, param.enableRayDrag, true, k_RotationPieColor);
            }

            color = temp;
            return(rotation);
        }
        static Vector3 DoPlanarHandle(
            int id,
            int planePrimaryAxis,
            Vector3 position,
            Vector3 offset,
            Quaternion rotation,
            float handleSize,
            float cameraLerp,
            Vector3 viewVectorDrawSpace,
            PositionHandleParam.Orientation orientation)
        {
            var positionOffset = offset;

            var axis1index      = planePrimaryAxis;
            var axis2index      = (axis1index + 1) % 3;
            var axisNormalIndex = (axis1index + 2) % 3;

            Color prevColor = Handles.color;

            bool isStatic = (!Tools.s_Hidden && EditorApplication.isPlaying && GameObjectUtility.ContainsStatic(Selection.gameObjects));

            color = isStatic ? staticColor : GetColorByAxis(axisNormalIndex);
            color = Color.Lerp(color, Color.clear, cameraLerp);

            var updateOpacityFillColor = false;

            if (GUIUtility.hotControl == id)
            {
                color = selectedColor;
            }
            else if (HandleUtility.nearestControl == id)
            {
                color = preselectionColor;
            }
            else
            {
                updateOpacityFillColor = true;
            }

            color = ToActiveColorSpace(color);


            // NOTE: The planar transform handles always face toward the camera so they won't
            // obscure each other (unlike the X, Y, and Z axis handles which always face in the
            // positive axis directions). Whenever the octant that the camera is in (relative to
            // to the transform tool) changes, we need to move the planar transform handle
            // positions to the correct octant.

            // Comments below assume axis1 is X and axis2 is Z to make it easier to visualize things.

            // Shift the planar transform handle in the positive direction by half its
            // handleSize so that it doesn't overlap in the center of the transform gizmo,
            // and also move the handle origin into the octant that the camera is in.
            // Don't update the actant while dragging to avoid too much distraction.
            if (!currentlyDragging)
            {
                switch (orientation)
                {
                case PositionHandleParam.Orientation.Camera:
                    // Offset the X position of the handle in negative direction if camera is in the -X octants; otherwise positive.
                    // Test against -0.01 instead of 0 to give a little bias to the positive quadrants. This looks better in axis views.
                    s_PlanarHandlesOctant[axis1index] = (viewVectorDrawSpace[axis1index] > 0.01f ? -1 : 1);
                    // Likewise with the other axis.
                    s_PlanarHandlesOctant[axis2index] = (viewVectorDrawSpace[axis2index] > 0.01f ? -1 : 1);
                    break;

                case PositionHandleParam.Orientation.Signed:
                    s_PlanarHandlesOctant[axis1index] = 1;
                    s_PlanarHandlesOctant[axis2index] = 1;
                    break;
                }
            }
            Vector3 handleOffset = s_PlanarHandlesOctant;

            // Zero out the offset along the normal axis.
            handleOffset[axisNormalIndex] = 0;
            positionOffset = rotation * Vector3.Scale(positionOffset, handleOffset);
            // Rotate and scale the offset
            handleOffset = rotation * (handleOffset * handleSize * 0.5f);

            // Calculate 3 axes
            Vector3 axis1      = Vector3.zero;
            Vector3 axis2      = Vector3.zero;
            Vector3 axisNormal = Vector3.zero;

            axis1[axis1index]           = 1;
            axis2[axis2index]           = 1;
            axisNormal[axisNormalIndex] = 1;
            axis1      = rotation * axis1;
            axis2      = rotation * axis2;
            axisNormal = rotation * axisNormal;

            // Draw the "filler" color for the handle
            verts[0] = position + positionOffset + handleOffset + (axis1 + axis2) * handleSize * 0.5f;
            verts[1] = position + positionOffset + handleOffset + (-axis1 + axis2) * handleSize * 0.5f;
            verts[2] = position + positionOffset + handleOffset + (-axis1 - axis2) * handleSize * 0.5f;
            verts[3] = position + positionOffset + handleOffset + (axis1 - axis2) * handleSize * 0.5f;
            Color faceColor = updateOpacityFillColor ? new Color(color.r, color.g, color.b, 0.1f) : color;

            faceColor = ToActiveColorSpace(faceColor);
            Handles.DrawSolidRectangleWithOutline(verts, faceColor, Color.clear);

            // And then render the handle itself (this is the colored outline)
            position = Slider2D(id,
                                position,
                                handleOffset + positionOffset,
                                axisNormal,
                                axis1, axis2,
                                handleSize * 0.5f,
                                RectangleHandleCap,
                                GridSnapping.active ? Vector2.zero : new Vector2(SnapSettings.move[axis1index], SnapSettings.move[axis2index]),
                                false);

            Handles.color = prevColor;

            return(position);
        }
        static Vector3 DoPositionHandle_Internal(PositionHandleIds ids, Vector3 position, Quaternion rotation, PositionHandleParam param)
        {
            Color temp = color;

            bool isStatic = (!Tools.s_Hidden && EditorApplication.isPlaying && GameObjectUtility.ContainsStatic(Selection.gameObjects));

            // Calculate the camera view vector in Handle draw space
            // this handle the case where the matrix is skewed
            var handlePosition       = matrix.MultiplyPoint3x4(position);
            var drawToWorldMatrix    = matrix * Matrix4x4.TRS(position, rotation, Vector3.one);
            var invDrawToWorldMatrix = drawToWorldMatrix.inverse;
            var viewVectorDrawSpace  = GetCameraViewFrom(handlePosition, invDrawToWorldMatrix);

            var size = HandleUtility.GetHandleSize(position);

            // Calculate per axis camera lerp
            for (var i = 0; i < 3; ++i)
            {
                s_DoPositionHandle_Internal_CameraViewLerp[i] = ids[i] == GUIUtility.hotControl ? 0 : GetCameraViewLerpForWorldAxis(viewVectorDrawSpace, GetAxisVector(i));
            }
            // Calculate per plane camera lerp (xy, yz, xz)
            for (var i = 0; i < 3; ++i)
            {
                s_DoPositionHandle_Internal_CameraViewLerp[3 + i] = Mathf.Max(s_DoPositionHandle_Internal_CameraViewLerp[i], s_DoPositionHandle_Internal_CameraViewLerp[(i + 1) % 3]);
            }

            var isHot       = ids.Has(GUIUtility.hotControl);
            var axisOffset  = param.axisOffset;
            var planeOffset = param.planeOffset;

            if (isHot)
            {
                axisOffset  = Vector3.zero;
                planeOffset = Vector3.zero;
            }

            // Draw plane handles (xy, yz, xz)
            var planeSize = isHot ? param.planeSize + param.planeOffset : param.planeSize;

            for (var i = 0; i < 3; ++i)
            {
                if (!param.ShouldShow(3 + i) || isHot && ids[3 + i] != GUIUtility.hotControl)
                {
                    continue;
                }

                var cameraLerp = isHot ? 0 : s_DoPositionHandle_Internal_CameraViewLerp[3 + i];
                if (cameraLerp <= kCameraViewThreshold)
                {
                    var offset = planeOffset * size;
                    offset[s_DoPositionHandle_Internal_PrevIndex[i]] = 0;
                    var planarSize = Mathf.Max(planeSize[i], planeSize[s_DoPositionHandle_Internal_NextIndex[i]]);
                    position = DoPlanarHandle(ids[3 + i], i, position, offset, rotation, size * planarSize, cameraLerp, viewVectorDrawSpace, param.planeOrientation);
                }
            }

            // Draw axis sliders
            // Draw last to have priority over the planes
            for (var i = 0; i < 3; ++i)
            {
                if (!param.ShouldShow(i))
                {
                    continue;
                }

                if (!currentlyDragging)
                {
                    switch (param.axesOrientation)
                    {
                    case PositionHandleParam.Orientation.Camera:
                        s_DoPositionHandle_AxisHandlesOctant[i] = viewVectorDrawSpace[i] > 0.01f ? -1 : 1;
                        break;

                    case PositionHandleParam.Orientation.Signed:
                        s_DoPositionHandle_AxisHandlesOctant[i] = 1;
                        break;
                    }
                }

                var isThisAxisHot = isHot && ids[i] == GUIUtility.hotControl;

                var axisColor = GetColorByAxis(i);
                color = isStatic ? Color.Lerp(axisColor, staticColor, staticBlend) : axisColor;
                GUI.SetNextControlName(s_DoPositionHandle_Internal_AxisNames[i]);

                // if we are hot here, the hot handle must be opaque
                var cameraLerp = isThisAxisHot ? 0 : s_DoPositionHandle_Internal_CameraViewLerp[i];

                if (cameraLerp <= kCameraViewThreshold)
                {
                    color = Color.Lerp(color, Color.clear, cameraLerp);
                    var axisVector = GetAxisVector(i);
                    var dir        = rotation * axisVector;
                    var offset     = dir * axisOffset[i] * size;

                    dir    *= s_DoPositionHandle_AxisHandlesOctant[i];
                    offset *= s_DoPositionHandle_AxisHandlesOctant[i];

                    if (isHot && !isThisAxisHot)
                    {
                        color = s_DisabledHandleColor;
                    }

                    // A plane with this axis is hot
                    if (isHot && (ids[s_DoPositionHandle_Internal_PrevPlaneIndex[i]] == GUIUtility.hotControl || ids[i + 3] == GUIUtility.hotControl))
                    {
                        color = selectedColor;
                    }

                    color = ToActiveColorSpace(color);

                    s_DoPositionHandle_ArrowCapConeOffset = isHot
                        ? rotation * Vector3.Scale(Vector3.Scale(axisVector, param.axisOffset), s_DoPositionHandle_AxisHandlesOctant)
                        : Vector3.zero;
                    position = Slider(ids[i], position, offset, dir, size * param.axisSize[i], DoPositionHandle_ArrowCap, GridSnapping.active ? 0f : SnapSettings.move[i]);
                }
            }

            VertexSnapping.HandleMouseMove(ids.xyz);
            if (param.ShouldShow(PositionHandleParam.Handle.XYZ) && (isHot && ids.xyz == GUIUtility.hotControl || !isHot))
            {
                color = ToActiveColorSpace(centerColor);
                GUI.SetNextControlName("FreeMoveAxis");
                position = FreeMoveHandle(ids.xyz, position, rotation, size * kFreeMoveHandleSizeFactor, GridSnapping.active ? Vector3.zero : SnapSettings.move, RectangleHandleCap);
            }

            color = temp;

            if (GridSnapping.active)
            {
                position = GridSnapping.Snap(position);
            }

            return(position);
        }
Пример #9
0
        internal static Vector3 DoScaleHandle(ScaleHandleIds ids, Vector3 scale, Vector3 position, Quaternion rotation, float handleSize, ScaleHandleParam param)
        {
            // Calculate the camera view vector in Handle draw space
            // this handle the case where the matrix is skewed
            var handlePosition       = matrix.MultiplyPoint3x4(position);
            var drawToWorldMatrix    = matrix * Matrix4x4.TRS(position, rotation, Vector3.one);
            var invDrawToWorldMatrix = drawToWorldMatrix.inverse;
            var viewVectorDrawSpace  = GetCameraViewFrom(handlePosition, invDrawToWorldMatrix);

            var isStatic = (!Tools.s_Hidden && EditorApplication.isPlaying && GameObjectUtility.ContainsStatic(Selection.gameObjects));

            var isHot = ids.Has(GUIUtility.hotControl);

            var axisOffset    = param.axisOffset;
            var axisLineScale = param.axisLineScale;

            // When an axis is hot, draw the line from the center to the handle
            // So ignore the offset
            if (isHot)
            {
                axisLineScale += axisOffset;
                axisOffset     = Vector3.zero;
            }

            var isCenterIsHot = ids.xyz == GUIUtility.hotControl;

            for (var i = 0; i < 3; ++i)
            {
                if (!param.ShouldShow(i))
                {
                    continue;
                }

                if (!currentlyDragging)
                {
                    switch (param.orientation)
                    {
                    case ScaleHandleParam.Orientation.Signed:
                        s_DoScaleHandle_AxisHandlesOctant[i] = 1;
                        break;

                    case ScaleHandleParam.Orientation.Camera:
                        s_DoScaleHandle_AxisHandlesOctant[i] = viewVectorDrawSpace[i] > 0.01f ? -1 : 1;
                        break;
                    }
                }


                var id            = ids[i];
                var isThisAxisHot = isHot && id == GUIUtility.hotControl;

                var axisDir    = GetAxisVector(i);
                var axisColor  = GetColorByAxis(i);
                var offset     = axisOffset[i];
                var cameraLerp = id == GUIUtility.hotControl ? 0 : GetCameraViewLerpForWorldAxis(viewVectorDrawSpace, axisDir);
                // If we are here and is hot, then this axis is hot and must be opaque
                cameraLerp = isHot ? 0 : cameraLerp;
                color      = isStatic ? Color.Lerp(axisColor, staticColor, staticBlend) : axisColor;

                axisDir *= s_DoScaleHandle_AxisHandlesOctant[i];

                if (cameraLerp <= kCameraViewThreshold)
                {
                    color = Color.Lerp(color, Color.clear, cameraLerp);

                    if (isHot && !isThisAxisHot)
                    {
                        color = s_DisabledHandleColor;
                    }
                    if (isCenterIsHot)
                    {
                        color = selectedColor;
                    }

                    color = ToActiveColorSpace(color);

                    scale[i] = UnityEditorInternal.SliderScale.DoAxis(
                        id,
                        scale[i],
                        position,
                        rotation * axisDir,
                        rotation,
                        handleSize * param.axisSize[i],
                        SnapSettings.scale,
                        offset,
                        axisLineScale[i]);
                }
            }

            if (param.ShouldShow(ScaleHandleParam.Handle.XYZ) && (isHot && ids.xyz == GUIUtility.hotControl || !isHot))
            {
                color = ToActiveColorSpace(centerColor);
                EditorGUI.BeginChangeCheck();
                var s = ScaleValueHandle(ids.xyz, scale.x, position, rotation, handleSize * param.xyzSize, CubeHandleCap, SnapSettings.scale);
                if (EditorGUI.EndChangeCheck() && !Mathf.Approximately(scale.x, 0))
                {
                    var dif = s / scale.x;
                    scale.x  = s;
                    scale.y *= dif;
                    scale.z *= dif;
                }
            }

            return(scale);
        }
Пример #10
0
 protected virtual bool ShouldToolGUIBeDisabled(out GUIContent disabledLabel)
 {
     disabledLabel = Handles.s_StaticLabel;
     return(!Tools.s_Hidden && EditorApplication.isPlaying && GameObjectUtility.ContainsStatic(Selection.gameObjects));
 }