protected override void OnRenderObject() { if (Camera.current != EditorCamera.Instance.Camera) { return; } base.OnRenderObject(); if (_targetObject == null) { return; } GLPrimitives.DrawWireOOBB(_targetOOBB, _lineColor, MaterialPool.Instance.GLLine); foreach (var dragHandle in _dragHandles) { if (!dragHandle.IsVisible) { continue; } if (!_axesVisibilityMask[(int)dragHandle.Axis]) { continue; } Color handleColor = (_hoveredDragHandle >= 0 && dragHandle.VolumeFace == (BoxFace)_hoveredDragHandle) ? _selectedAxisColor : _axesColors[(int)dragHandle.Axis]; GLPrimitives.Draw2DFilledRectangle(dragHandle.ScreenRect, handleColor, MaterialPool.Instance.Geometry2D, EditorCamera.Instance.Camera); } }
public void Render() { if (!_isVisible) { return; } Camera editorCamera = EditorCamera.Instance.Camera; Transform cameraTransform = editorCamera.transform; float zoom = Mathf.Abs(cameraTransform.position.y); int p0 = MathHelper.GetNumberOfDigits((int)zoom) - 1; int p1 = p0 + 1; float s0 = Mathf.Pow(10.0f, p0); float s1 = Mathf.Pow(10.0f, p1); Material material = MaterialPool.Instance.XZGrid; material.SetFloat("_CamFarPlane", editorCamera.farClipPlane); material.SetVector("_CamLook", editorCamera.transform.forward); material.SetFloat("_FadeScale", zoom / 10.0f); float alphaScale = Mathf.Clamp(1.0f - ((zoom - s0) / (s1 - s0)), 0.0f, 1.0f); GLPrimitives.DrawGridLines(_cellSizeX * s0, _cellSizeZ * s0, editorCamera, material, new Color(_lineColor.r, _lineColor.g, _lineColor.b, _lineColor.a * alphaScale)); GLPrimitives.DrawGridLines(_cellSizeX * s1, _cellSizeZ * s1, editorCamera, material, new Color(_lineColor.r, _lineColor.g, _lineColor.b, _lineColor.a - _lineColor.a * alphaScale)); }
/// <summary> /// Renders the object selection rectangle if it was marked as visible. /// </summary> public override void Render() { if (_isVisible) { GLPrimitives.Draw2DFilledRectangle(_enclosingRectangle, _renderSettings.FillColor, MaterialPool.Instance.Geometry2D, EditorCamera.Instance.Camera); GLPrimitives.Draw2DRectangleBorderLines(_enclosingRectangle, _renderSettings.BorderLineColor, MaterialPool.Instance.GLLine, EditorCamera.Instance.Camera); } }
/// <summary> /// Renders the selection boxes for the specified selected game objects. /// </summary> public override void RenderObjectSelectionBoxes(HashSet <GameObject> selectedObjects) { // Cache needed data EditorObjectSelection editorObjectSelecton = EditorObjectSelection.Instance; Material lineRenderingMaterial = MaterialPool.Instance.GLLine; ObjectSelectionSettings objectSelectionSettings = editorObjectSelecton.ObjectSelectionSettings; ObjectSelectionBoxRenderSettings objectSelectionBoxRenderSettings = objectSelectionSettings.ObjectSelectionBoxRenderSettings; // Create the object selection box calculator instance. // Note: This can be null if the user has activated the 'Custom' object selection mode // but hasn't specified a selection box calculator. ObjectSelectionBoxCalculator objectSelectionBoxCalculator = ObjectSelectionBoxCalculatorFactory.Create(objectSelectionSettings.ObjectSelectionMode); if (objectSelectionBoxCalculator != null) { // Calculate and retrieve the selection boxes and then render them List <ObjectSelectionBox> objectSelectionBoxes = objectSelectionBoxCalculator.CalculateForObjectSelection(selectedObjects); GLPrimitives.DrawCornerLinesForSelectionBoxes(objectSelectionBoxes, objectSelectionBoxRenderSettings.BoxSizeAdd, objectSelectionBoxRenderSettings.SelectionBoxCornerLinePercentage, EditorCamera.Instance.Camera, objectSelectionBoxRenderSettings.SelectionBoxLineColor, lineRenderingMaterial); } }
/// <summary> /// Renders the selection boxes for the specified selected game objects. /// </summary> public override void RenderObjectSelectionBoxes(HashSet <GameObject> selectedObjects) { // Cache needed data EditorObjectSelection editorObjectSelecton = EditorObjectSelection.Instance; Material lineRenderingMaterial = MaterialPool.Instance.GLLine; ObjectSelectionSettings objectSelectionSettings = editorObjectSelecton.ObjectSelectionSettings; ObjectSelectionBoxRenderSettings objectSelectionBoxRenderSettings = objectSelectionSettings.ObjectSelectionBoxRenderSettings; if (objectSelectionBoxRenderSettings.SelectionBoxRenderMode == ObjectSelectionBoxRenderMode.PerObject) { List <ObjectSelectionBox> objectSelectionBoxes = ObjectSelectionBoxCalculator.CalculatePerObject(selectedObjects); GLPrimitives.DrawCornerLinesForSelectionBoxes(objectSelectionBoxes, objectSelectionBoxRenderSettings.BoxSizeAdd, objectSelectionBoxRenderSettings.SelectionBoxCornerLinePercentage, EditorCamera.Instance.Camera, objectSelectionBoxRenderSettings.SelectionBoxLineColor, lineRenderingMaterial); } else if (objectSelectionBoxRenderSettings.SelectionBoxRenderMode == ObjectSelectionBoxRenderMode.FromParentToBottom) { List <ObjectSelectionBox> objectSelectionBoxes = ObjectSelectionBoxCalculator.CalculateFromParentsToBottom(selectedObjects); GLPrimitives.DrawCornerLinesForSelectionBoxes(objectSelectionBoxes, objectSelectionBoxRenderSettings.BoxSizeAdd, objectSelectionBoxRenderSettings.SelectionBoxCornerLinePercentage, EditorCamera.Instance.Camera, objectSelectionBoxRenderSettings.SelectionBoxLineColor, lineRenderingMaterial); } }