更新到0.6.0.2
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
namespace DrawXXL
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
[HelpURL("https://www.symphonygames.net/drawxxldocumentation/index.html")]
|
||||
[AddComponentMenu("Xeric Library/DebugDrawLibrary/Screenspace/Camera Grid Visualizer")]
|
||||
[DefaultExecutionOrder(31000)] //negative numers are early, positive numbers are late. Range is till 32000 to both negative and positive direction.
|
||||
public class CameraGridVisualizer : VisualizerScreenspaceParent
|
||||
{
|
||||
[SerializeField] Color color = DrawBasics.defaultColor;
|
||||
[SerializeField] [Range(0.0f, 0.1f)] float linesWidth_relToViewportHeight = 0.0f;
|
||||
[SerializeField] bool drawTenthLines = true;
|
||||
[SerializeField] bool drawHundredthLines = true;
|
||||
[SerializeField] DrawEngineBasics.GridScreenspaceMode gridScreenspaceMode = DrawEngineBasics.GridScreenspaceMode.warpWidthAndHeightIndividuallyToFitScreenInBothAxes;
|
||||
|
||||
public override void InitializeValues_onceInComponentLifetime()
|
||||
{
|
||||
TrySetTextToEmptyString();
|
||||
}
|
||||
|
||||
public override void InitializeValues_alsoOnPlaymodeEnter_andOnComponentCreatedAsCopy()
|
||||
{
|
||||
TryFetchCamOnThisGO_andDecideScreenspaceDefiningCamera();
|
||||
}
|
||||
|
||||
public override void DrawVisualizedObject()
|
||||
{
|
||||
Camera usedCamera = Get_usedCamera("Camera Grid Visualizer Component");
|
||||
if (usedCamera != null)
|
||||
{
|
||||
DrawEngineBasics.GridScreenspace(usedCamera, color, linesWidth_relToViewportHeight, drawTenthLines, drawHundredthLines, gridScreenspaceMode, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bed2be6d23f8c0f4aa4be27ce39bf45e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,309 @@
|
||||
namespace DrawXXL
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
[HelpURL("https://www.symphonygames.net/drawxxldocumentation/index.html")]
|
||||
[AddComponentMenu("Xeric Library/DebugDrawLibrary/Screenspace/Line Drawer Screenspace")]
|
||||
[DefaultExecutionOrder(31000)] //negative numers are early, positive numbers are late. Range is till 32000 to both negative and positive direction.
|
||||
public class LineDrawerScreenspace : VisualizerScreenspaceParent
|
||||
{
|
||||
[SerializeField] LineDrawer.LineType lineType = LineDrawer.LineType.standardLine;
|
||||
[SerializeField] LineDrawer.LineDefinitionMode lineDefinitionMode = LineDrawer.LineDefinitionMode.startPositionAndEndPosition;
|
||||
[SerializeField] public bool lineDefinitionSection1_isOutfolded = false; //is only "public" to silence the compiler warning saying that it is "never used". The compiler doesn't know that it is used via serialization.
|
||||
[SerializeField] public bool lineDefinitionSection2_isOutfolded = false; //is only "public" to silence the compiler warning saying that it is "never used". The compiler doesn't know that it is used via serialization.
|
||||
|
||||
//Shared:
|
||||
[SerializeField] bool interpretDirectionAsUnwarped = false;
|
||||
[SerializeField] Color startColor = DrawBasics.defaultColor;
|
||||
[SerializeField] bool useDifferentEndColor = false;
|
||||
[SerializeField] Color endColor = UtilitiesDXXL_Colors.red_boolFalse;
|
||||
[SerializeField] [Range(0.0f, 0.15f)] float lineWidth_relToViewportHeight = 0.0f;
|
||||
[SerializeField] DrawBasics.LineStyle lineStyle = DrawBasics.LineStyle.solid;
|
||||
[SerializeField] float stylePatternScaleFactor = 1.0f;
|
||||
[SerializeField] bool animationDuringEditMode = true;
|
||||
[SerializeField] float animationSpeed = 0.0f;
|
||||
LineAnimationProgress precedingLineAnimationProgress = new LineAnimationProgress();
|
||||
[SerializeField] bool enlargeSmallTextToThisMinTextSize = true;
|
||||
[SerializeField] [Range(0.0f, 0.3f)] float enlargeSmallTextToThisMinRelTextSize_value = DrawScreenspace.minTextSize_relToViewportHeight;
|
||||
[SerializeField] LineDrawer.EndPlatesConfig endPlatesConfig = LineDrawer.EndPlatesConfig.disabled;
|
||||
[SerializeField] [Range(0.0f, 0.5f)] float endPlatesSize_relToViewportHeight = 0.1f; //is initially disabled due to "endPlatesConfig"
|
||||
[SerializeField] [Range(0.0f, 0.5f)] float alphaFadeOutLength_0to1 = 0.0f;
|
||||
[SerializeField] bool shiftTextPosOnLines_toNonIntersecting = false;
|
||||
[SerializeField] [Range(0.05f, 10.0f)] float relSizeOfTextOnLines = 0.45f;
|
||||
|
||||
//Vectors:
|
||||
[SerializeField] LineDrawer.ConesConfig conesConfig = LineDrawer.ConesConfig.onlyAtEnd;
|
||||
[SerializeField] [Range(0.0f, 0.3f)] float coneLength_relToViewportHeight = 0.05f;
|
||||
[SerializeField] bool writeComponentValuesAsText = false;
|
||||
|
||||
//Vectors With Extention:
|
||||
[SerializeField] bool displayDistanceOutsideScreenBorder = true;
|
||||
|
||||
//Blinking Line:
|
||||
[SerializeField] Color blinkColor = UtilitiesDXXL_Colors.Get_color_butWithAdjustedAlpha(DrawBasics.defaultColor, 0.2f);
|
||||
[SerializeField] float blinkDurationInSec = 0.5f;
|
||||
|
||||
//Line under tension:
|
||||
[SerializeField] [Range(0.001f, 2.0f)] public float relaxedLength_relToViewportHeight = 0.4f;
|
||||
[SerializeField] public float stretchFactor_forStretchedTensionColor = 2.0f;
|
||||
[SerializeField] public float stretchFactor_forSqueezedTensionColor = 0.0f;
|
||||
[SerializeField] public DrawBasics.LineStyle lineStyle_underTension = DrawBasics.LineStyle.sine;
|
||||
[SerializeField] public Color relaxedColor = UtilitiesDXXL_Colors.green_boolTrue;
|
||||
[SerializeField] public Color color_forStretchedTension = UtilitiesDXXL_Colors.red_boolFalse;
|
||||
[SerializeField] public Color color_forSqueezedTension = UtilitiesDXXL_Colors.red_boolFalse;
|
||||
[SerializeField] [Range(0.0f, 1.0f)] public float alphaOfReferenceLengthDisplay = 0.1f;
|
||||
|
||||
//Moving arrows line:
|
||||
[SerializeField] [Range(0.0f, 0.15f)] float lineWidth_ofMovingArrowsLine_relToViewportHeight = 0.016f;
|
||||
[SerializeField] float animationSpeed_ofMovingArrowsLine = 0.5f;
|
||||
[SerializeField] [Range(0.02f, 0.5f)] float distanceBetweenArrows_relToViewportHeight = 0.11f;
|
||||
[SerializeField] [Range(0.01f, 0.3f)] float lengthOfArrows_relToViewportHeight = 0.05f;
|
||||
[SerializeField] bool backwardAnimationFlipsArrowDirection = true;
|
||||
|
||||
//Line with alternating colors:
|
||||
[SerializeField] Color alternatingColor = DrawBasics.defaultColor2_ofAlternatingColorLines;
|
||||
[SerializeField] [Range(0.001f, 0.2f)] float lengthOfStripes_relToViewportHeight = 0.03f;
|
||||
|
||||
public override void InitializeValues_onceInComponentLifetime()
|
||||
{
|
||||
TrySetTextToEmptyString();
|
||||
|
||||
customVector2Configs[0].picker_isOutfolded = true;
|
||||
customVector2Configs[0].source = CustomVector2Source.manualInput;
|
||||
customVector2Configs[0].clipboardForManualInput = 0.4f * Vector2.one;
|
||||
customVector2Configs[0].vectorInterpretation = VectorInterpretation.globalSpace;
|
||||
|
||||
positionInsideViewport0to1 = new Vector2(0.3f, 0.3f);//-> initial line start position
|
||||
positionInsideViewport0to1_v2 = new Vector2(0.7f, 0.7f);//-> initial line end position
|
||||
}
|
||||
|
||||
public override void InitializeValues_alsoOnPlaymodeEnter_andOnComponentCreatedAsCopy()
|
||||
{
|
||||
TryFetchCamOnThisGO_andDecideScreenspaceDefiningCamera();
|
||||
}
|
||||
|
||||
public override void DrawVisualizedObject()
|
||||
{
|
||||
Camera usedCamera = Get_usedCamera("Shape Drawer Screenspace Component");
|
||||
if (usedCamera != null)
|
||||
{
|
||||
float used_enlargeSmallTextToThisMinRelTextSize_value = enlargeSmallTextToThisMinTextSize ? enlargeSmallTextToThisMinRelTextSize_value : 0.0f;
|
||||
float used_endPlatesSize_relToViewportHeight = Set_endPlatesConfig_reversible();
|
||||
UtilitiesDXXL_DrawBasics.Set_shiftTextPosOnLines_toNonIntersecting_reversible(shiftTextPosOnLines_toNonIntersecting);
|
||||
UtilitiesDXXL_DrawBasics.Set_relSizeOfTextOnLines_reversible(relSizeOfTextOnLines);
|
||||
GetLineStartPosAndDirection(out Vector2 lineStartPosition, out Vector2 vector_fromLineStart_toLineEnd_inAspectWarpedScreenspace, usedCamera);
|
||||
bool used_interpretDirectionAsUnwarped = false; //-> "GetLineStartPosAndDirection()" already cares for "interpretDirectionAsUnwarped"
|
||||
|
||||
switch (lineType)
|
||||
{
|
||||
case LineDrawer.LineType.standardLine:
|
||||
if (useDifferentEndColor)
|
||||
{
|
||||
precedingLineAnimationProgress = LineFrom_fadeableAnimSpeed_screenspace.InternalDraw_withColorFade(usedCamera, lineStartPosition, vector_fromLineStart_toLineEnd_inAspectWarpedScreenspace, startColor, endColor, lineWidth_relToViewportHeight, text_inclGlobalMarkupTags, used_interpretDirectionAsUnwarped, lineStyle, stylePatternScaleFactor, animationSpeed, precedingLineAnimationProgress, used_endPlatesSize_relToViewportHeight, alphaFadeOutLength_0to1, used_enlargeSmallTextToThisMinRelTextSize_value, 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
precedingLineAnimationProgress = LineFrom_fadeableAnimSpeed_screenspace.InternalDraw(usedCamera, lineStartPosition, vector_fromLineStart_toLineEnd_inAspectWarpedScreenspace, startColor, lineWidth_relToViewportHeight, text_inclGlobalMarkupTags, used_interpretDirectionAsUnwarped, lineStyle, stylePatternScaleFactor, animationSpeed, precedingLineAnimationProgress, used_endPlatesSize_relToViewportHeight, alphaFadeOutLength_0to1, used_enlargeSmallTextToThisMinRelTextSize_value, 0.0f);
|
||||
}
|
||||
break;
|
||||
case LineDrawer.LineType.vector:
|
||||
switch (conesConfig)
|
||||
{
|
||||
case LineDrawer.ConesConfig.bothSides:
|
||||
DrawScreenspace.VectorFrom(usedCamera, lineStartPosition, vector_fromLineStart_toLineEnd_inAspectWarpedScreenspace, startColor, lineWidth_relToViewportHeight, text_inclGlobalMarkupTags, used_interpretDirectionAsUnwarped, coneLength_relToViewportHeight, true, writeComponentValuesAsText, used_endPlatesSize_relToViewportHeight, 0.0f);
|
||||
break;
|
||||
case LineDrawer.ConesConfig.onlyAtStart:
|
||||
DrawScreenspace.VectorTo(usedCamera, -vector_fromLineStart_toLineEnd_inAspectWarpedScreenspace, lineStartPosition, startColor, lineWidth_relToViewportHeight, text_inclGlobalMarkupTags, used_interpretDirectionAsUnwarped, coneLength_relToViewportHeight, false, writeComponentValuesAsText, used_endPlatesSize_relToViewportHeight, 0.0f);
|
||||
break;
|
||||
case LineDrawer.ConesConfig.onlyAtEnd:
|
||||
DrawScreenspace.VectorFrom(usedCamera, lineStartPosition, vector_fromLineStart_toLineEnd_inAspectWarpedScreenspace, startColor, lineWidth_relToViewportHeight, text_inclGlobalMarkupTags, used_interpretDirectionAsUnwarped, coneLength_relToViewportHeight, false, writeComponentValuesAsText, used_endPlatesSize_relToViewportHeight, 0.0f);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case LineDrawer.LineType.vectorWithExtention:
|
||||
DrawEngineBasics.RayLineExtendedScreenspace(usedCamera, lineStartPosition, vector_fromLineStart_toLineEnd_inAspectWarpedScreenspace, startColor, lineWidth_relToViewportHeight, text_inclGlobalMarkupTags, used_interpretDirectionAsUnwarped, coneLength_relToViewportHeight, displayDistanceOutsideScreenBorder, 0.0f);
|
||||
break;
|
||||
case LineDrawer.LineType.blinkingLine:
|
||||
float used_blinkDurationInSec = ((Application.isPlaying == false) && (animationDuringEditMode == false)) ? float.MaxValue : blinkDurationInSec; //-> this prevents a problem in the situation where "animationDuringEditMode" has been disabled in a blink phase where the line is not possible. Otherwise in such cases the line would permanently invisible.
|
||||
DrawScreenspace.BlinkingRay(usedCamera, lineStartPosition, vector_fromLineStart_toLineEnd_inAspectWarpedScreenspace, startColor, used_blinkDurationInSec, lineWidth_relToViewportHeight, text_inclGlobalMarkupTags, used_interpretDirectionAsUnwarped, lineStyle, blinkColor, stylePatternScaleFactor, used_endPlatesSize_relToViewportHeight, alphaFadeOutLength_0to1, used_enlargeSmallTextToThisMinRelTextSize_value, 0.0f);
|
||||
break;
|
||||
case LineDrawer.LineType.lineUnderTension:
|
||||
DrawScreenspace.RayUnderTension(usedCamera, lineStartPosition, vector_fromLineStart_toLineEnd_inAspectWarpedScreenspace, relaxedLength_relToViewportHeight, relaxedColor, lineStyle_underTension, stretchFactor_forStretchedTensionColor, color_forStretchedTension, stretchFactor_forSqueezedTensionColor, color_forSqueezedTension, lineWidth_relToViewportHeight, text_inclGlobalMarkupTags, alphaOfReferenceLengthDisplay, used_interpretDirectionAsUnwarped, stylePatternScaleFactor, used_endPlatesSize_relToViewportHeight, used_enlargeSmallTextToThisMinRelTextSize_value, 0.0f);
|
||||
break;
|
||||
case LineDrawer.LineType.movingArrowsLine:
|
||||
precedingLineAnimationProgress = MovingArrowsRay_fadeableAnimSpeed_screenspace.InternalDraw(usedCamera, lineStartPosition, vector_fromLineStart_toLineEnd_inAspectWarpedScreenspace, startColor, lineWidth_ofMovingArrowsLine_relToViewportHeight, distanceBetweenArrows_relToViewportHeight, lengthOfArrows_relToViewportHeight, text_inclGlobalMarkupTags, animationSpeed_ofMovingArrowsLine, precedingLineAnimationProgress, backwardAnimationFlipsArrowDirection, used_interpretDirectionAsUnwarped, used_endPlatesSize_relToViewportHeight, 0.0f);
|
||||
break;
|
||||
case LineDrawer.LineType.lineWithAlternatingColors:
|
||||
precedingLineAnimationProgress = RayWithAlternatingColors_fadeableAnimSpeed_screenspace.InternalDraw(usedCamera, lineStartPosition, vector_fromLineStart_toLineEnd_inAspectWarpedScreenspace, startColor, alternatingColor, lineWidth_relToViewportHeight, lengthOfStripes_relToViewportHeight, text_inclGlobalMarkupTags, used_interpretDirectionAsUnwarped, animationSpeed, precedingLineAnimationProgress, used_endPlatesSize_relToViewportHeight, alphaFadeOutLength_0to1, 0.0f);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
UtilitiesDXXL_DrawBasics.Reverse_shiftTextPosOnLines_toNonIntersecting();
|
||||
UtilitiesDXXL_DrawBasics.Reverse_relSizeOfTextOnLines();
|
||||
Reverse_endPlatesConfig();
|
||||
|
||||
TrySheduleRepaintSceneViewForAnimationOutsidePlaymode();
|
||||
}
|
||||
}
|
||||
|
||||
void GetLineStartPosAndDirection(out Vector2 lineStartPosition, out Vector2 vector_fromLineStart_toLineEnd_inAspectWarpedScreenspace, Camera usedCamera)
|
||||
{
|
||||
Vector2 lineEndPosition;
|
||||
switch (lineDefinitionMode)
|
||||
{
|
||||
case LineDrawer.LineDefinitionMode.startPositionAndEndPosition:
|
||||
lineStartPosition = positionInsideViewport0to1;
|
||||
lineEndPosition = positionInsideViewport0to1_v2;
|
||||
vector_fromLineStart_toLineEnd_inAspectWarpedScreenspace = lineEndPosition - lineStartPosition;
|
||||
break;
|
||||
case LineDrawer.LineDefinitionMode.startPositionAndDirectionVectorToEndPosition:
|
||||
lineStartPosition = positionInsideViewport0to1;
|
||||
vector_fromLineStart_toLineEnd_inAspectWarpedScreenspace = Get_vector_fromLineStart_toLineEnd_inAspectWarpedScreenspace(usedCamera);
|
||||
break;
|
||||
case LineDrawer.LineDefinitionMode.endPositionAndDirectionVectorToIt:
|
||||
lineEndPosition = positionInsideViewport0to1_v2;
|
||||
vector_fromLineStart_toLineEnd_inAspectWarpedScreenspace = Get_vector_fromLineStart_toLineEnd_inAspectWarpedScreenspace(usedCamera);
|
||||
lineStartPosition = lineEndPosition - vector_fromLineStart_toLineEnd_inAspectWarpedScreenspace;
|
||||
break;
|
||||
default:
|
||||
lineStartPosition = Vector2.zero;
|
||||
vector_fromLineStart_toLineEnd_inAspectWarpedScreenspace = Vector2.one;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Vector2 Get_vector_fromLineStart_toLineEnd_inAspectWarpedScreenspace(Camera usedCamera)
|
||||
{
|
||||
if (interpretDirectionAsUnwarped || (customVector2Configs[0].source == CustomVector2Source.rotationAroundZStartingFromRight))
|
||||
{
|
||||
return DrawScreenspace.DirectionInUnitsOfUnwarpedSpace_to_sameLookingDirectionInUnitsOfWarpedSpace(Get_customVector2_1_inGlobalSpaceUnits(), usedCamera);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Get_customVector2_1_inGlobalSpaceUnits();
|
||||
}
|
||||
}
|
||||
|
||||
float Set_endPlatesConfig_reversible()
|
||||
{
|
||||
if (endPlatesConfig == LineDrawer.EndPlatesConfig.disabled)
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (endPlatesConfig)
|
||||
{
|
||||
case LineDrawer.EndPlatesConfig.bothSides:
|
||||
UtilitiesDXXL_DrawBasics.Set_disableEndPlates_atLineStart_reversible(false);
|
||||
UtilitiesDXXL_DrawBasics.Set_disableEndPlates_atLineEnd_reversible(false);
|
||||
break;
|
||||
case LineDrawer.EndPlatesConfig.onlyAtStart:
|
||||
UtilitiesDXXL_DrawBasics.Set_disableEndPlates_atLineStart_reversible(false);
|
||||
UtilitiesDXXL_DrawBasics.Set_disableEndPlates_atLineEnd_reversible(true);
|
||||
break;
|
||||
case LineDrawer.EndPlatesConfig.onlyAtEnd:
|
||||
UtilitiesDXXL_DrawBasics.Set_disableEndPlates_atLineStart_reversible(true);
|
||||
UtilitiesDXXL_DrawBasics.Set_disableEndPlates_atLineEnd_reversible(false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return endPlatesSize_relToViewportHeight;
|
||||
}
|
||||
}
|
||||
|
||||
void Reverse_endPlatesConfig()
|
||||
{
|
||||
if (endPlatesConfig != LineDrawer.EndPlatesConfig.disabled)
|
||||
{
|
||||
UtilitiesDXXL_DrawBasics.Reverse_disableEndPlates_atLineStart();
|
||||
UtilitiesDXXL_DrawBasics.Reverse_disableEndPlates_atLineEnd();
|
||||
}
|
||||
}
|
||||
|
||||
void TrySheduleRepaintSceneViewForAnimationOutsidePlaymode()
|
||||
{
|
||||
if (animationDuringEditMode)
|
||||
{
|
||||
if (Application.isPlaying == false)
|
||||
{
|
||||
if (DrawnLineUsesAnimation(true))
|
||||
{
|
||||
UtilitiesDXXL_Components.currentVirtualOnDrawGizmoCycle_shouldRepaintAllViews = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool DrawnLineUsesAnimation(bool returnFalseForAnimationSpeedOfZero)
|
||||
{
|
||||
if (lineType == LineDrawer.LineType.standardLine)
|
||||
{
|
||||
if (UtilitiesDXXL_LineStyles.CheckIfLineStyleIsAnimatable(lineStyle))
|
||||
{
|
||||
if (UtilitiesDXXL_Math.ApproximatelyZero(animationSpeed))
|
||||
{
|
||||
return (!returnFalseForAnimationSpeedOfZero);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lineType == LineDrawer.LineType.lineWithAlternatingColors)
|
||||
{
|
||||
if (UtilitiesDXXL_Math.ApproximatelyZero(animationSpeed))
|
||||
{
|
||||
return (!returnFalseForAnimationSpeedOfZero);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (lineType == LineDrawer.LineType.movingArrowsLine)
|
||||
{
|
||||
if (UtilitiesDXXL_Math.ApproximatelyZero(animationSpeed_ofMovingArrowsLine))
|
||||
{
|
||||
return (!returnFalseForAnimationSpeedOfZero);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (lineType == LineDrawer.LineType.blinkingLine)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public float GetLineLength_relToViewportHeight()
|
||||
{
|
||||
Camera usedCamera = Get_usedCamera("Shape Drawer Screenspace Component");
|
||||
if (usedCamera != null)
|
||||
{
|
||||
GetLineStartPosAndDirection(out Vector2 lineStartPosition, out Vector2 vector_fromLineStart_toLineEnd_inAspectWarpedScreenspace, usedCamera);
|
||||
Vector2 vector_fromLineStart_toLineEnd_inUnwarpedScreenspace = DrawScreenspace.DirectionInUnitsOfWarpedSpace_to_sameLookingDirectionInUnitsOfUnwarpedSpace(vector_fromLineStart_toLineEnd_inAspectWarpedScreenspace, usedCamera);
|
||||
return vector_fromLineStart_toLineEnd_inUnwarpedScreenspace.magnitude;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8098e825ea019cd4d9096b73d43f298b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,126 @@
|
||||
namespace DrawXXL
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
[HelpURL("https://www.symphonygames.net/drawxxldocumentation/index.html")]
|
||||
[AddComponentMenu("Xeric Library/DebugDrawLibrary/Screenspace/Shape Drawer Screenspace")]
|
||||
[DefaultExecutionOrder(31000)] //negative numers are early, positive numbers are late. Range is till 32000 to both negative and positive direction.
|
||||
public class ShapeDrawerScreenspace : VisualizerScreenspaceParent
|
||||
{
|
||||
[SerializeField] ShapeDrawer2D.ShapeType shapeType = ShapeDrawer2D.ShapeType.circle;
|
||||
|
||||
//size definitions:
|
||||
[SerializeField] [Range(0.0f, 1.5f)] float radius_relToViewportHeight = 0.05f;
|
||||
[SerializeField] [Range(0.0f, 1.5f)] float width_relToViewportHeight_initialValue01 = 0.1f;
|
||||
[SerializeField] [Range(0.0f, 1.5f)] float height_relToViewportHeight_initialValue01 = 0.1f;
|
||||
[SerializeField] [Range(0.0f, 1.5f)] float height_relToViewportHeight_initialValue02 = 0.2f;
|
||||
[SerializeField] [Range(0.0f, 1.5f)] float sizeOfIcon_relToViewportHeight = 0.1f;
|
||||
|
||||
//other definitions:
|
||||
[SerializeField] [Range(-360.0f, 360.0f)] float zRotationDegCC = 0.0f;
|
||||
[SerializeField] Color color = DrawBasics.defaultColor;
|
||||
[SerializeField] [Range(0.0f, 0.2f)] float linesWidth_relToViewportHeight = 0.0f;
|
||||
[SerializeField] DrawBasics.LineStyle lineStyle = DrawBasics.LineStyle.solid;
|
||||
[SerializeField] float stylePatternScaleFactor = 1.0f;
|
||||
[SerializeField] DrawBasics.LineStyle fillStyle = DrawBasics.LineStyle.invisible;
|
||||
[SerializeField] float shapeFillDensity = 1.0f;
|
||||
[SerializeField] bool drawPointerIfOffscreen = true;
|
||||
[SerializeField] bool addTextForOutsideDistance_toOffscreenPointer = true;
|
||||
[SerializeField] DrawBasics.IconType iconType = DrawBasics.IconType.car;
|
||||
[SerializeField] bool iconIsMirroredHorizontally = false;
|
||||
[SerializeField] CapsuleDirection2D capusleDirection2D = CapsuleDirection2D.Vertical;
|
||||
[SerializeField] ShapeDrawer.CornerOptionsForIrregularStar cornerOptionsForIrregularStar = ShapeDrawer.CornerOptionsForIrregularStar._5;
|
||||
[SerializeField] bool drawHullEdgeLines_forScreenEncasingShapes = false;
|
||||
[SerializeField] float dotDensity = 1.0f;
|
||||
|
||||
public override void InitializeValues_onceInComponentLifetime()
|
||||
{
|
||||
TrySetTextToEmptyString();
|
||||
}
|
||||
|
||||
public override void InitializeValues_alsoOnPlaymodeEnter_andOnComponentCreatedAsCopy()
|
||||
{
|
||||
TryFetchCamOnThisGO_andDecideScreenspaceDefiningCamera();
|
||||
}
|
||||
|
||||
public override void DrawVisualizedObject()
|
||||
{
|
||||
Camera usedCamera = Get_usedCamera("Shape Drawer Screenspace Component");
|
||||
if (usedCamera != null)
|
||||
{
|
||||
UtilitiesDXXL_LineStyles.logWarningToConsole_forTooSmallPatternScaleFactor = false;
|
||||
switch (shapeType)
|
||||
{
|
||||
case ShapeDrawer2D.ShapeType.circle:
|
||||
float size_ofCircleHull = 2.0f * radius_relToViewportHeight;
|
||||
|
||||
UtilitiesDXXL_Shapes.Set_shapeFillDensity_reversible(shapeFillDensity);
|
||||
UtilitiesDXXL_Screenspace.DrawShape(usedCamera, positionInsideViewport0to1, DrawShapes.Shape2DType.circle, color, color, size_ofCircleHull, size_ofCircleHull, zRotationDegCC, linesWidth_relToViewportHeight, text_inclGlobalMarkupTags, lineStyle, stylePatternScaleFactor, fillStyle, drawPointerIfOffscreen, addTextForOutsideDistance_toOffscreenPointer, 0.0f, 1.0f, null, drawHullEdgeLines_forScreenEncasingShapes);
|
||||
UtilitiesDXXL_Shapes.Reverse_shapeFillDensity();
|
||||
break;
|
||||
case ShapeDrawer2D.ShapeType.ellipse:
|
||||
UtilitiesDXXL_Shapes.Set_shapeFillDensity_reversible(shapeFillDensity);
|
||||
UtilitiesDXXL_Screenspace.DrawShape(usedCamera, positionInsideViewport0to1, DrawShapes.Shape2DType.circle, color, color, width_relToViewportHeight_initialValue01, height_relToViewportHeight_initialValue02, zRotationDegCC, linesWidth_relToViewportHeight, text_inclGlobalMarkupTags, lineStyle, stylePatternScaleFactor, fillStyle, drawPointerIfOffscreen, addTextForOutsideDistance_toOffscreenPointer, 0.0f, 1.0f, null, drawHullEdgeLines_forScreenEncasingShapes);
|
||||
UtilitiesDXXL_Shapes.Reverse_shapeFillDensity();
|
||||
break;
|
||||
case ShapeDrawer2D.ShapeType.star:
|
||||
UtilitiesDXXL_Screenspace.DrawShape(usedCamera, positionInsideViewport0to1, ShapeDrawer.Get_shape2DType_forIrregularStar(cornerOptionsForIrregularStar), color, color, width_relToViewportHeight_initialValue01, height_relToViewportHeight_initialValue01, zRotationDegCC, linesWidth_relToViewportHeight, text_inclGlobalMarkupTags, lineStyle, stylePatternScaleFactor, DrawBasics.LineStyle.invisible, drawPointerIfOffscreen, addTextForOutsideDistance_toOffscreenPointer, 0.0f, 1.0f, null, drawHullEdgeLines_forScreenEncasingShapes);
|
||||
break;
|
||||
case ShapeDrawer2D.ShapeType.capsule:
|
||||
Vector2 sizeOfCapsule_relToViewportHeight = new Vector2(width_relToViewportHeight_initialValue01, height_relToViewportHeight_initialValue02);
|
||||
|
||||
UtilitiesDXXL_Shapes.Set_shapeFillDensity_reversible(shapeFillDensity);
|
||||
UtilitiesDXXL_Screenspace.Capsule(usedCamera, positionInsideViewport0to1, sizeOfCapsule_relToViewportHeight, color, capusleDirection2D, zRotationDegCC, linesWidth_relToViewportHeight, text_inclGlobalMarkupTags, drawPointerIfOffscreen, lineStyle, stylePatternScaleFactor, fillStyle, addTextForOutsideDistance_toOffscreenPointer, 0.0f, drawHullEdgeLines_forScreenEncasingShapes);
|
||||
UtilitiesDXXL_Shapes.Reverse_shapeFillDensity();
|
||||
break;
|
||||
case ShapeDrawer2D.ShapeType.icon:
|
||||
DrawScreenspace.Icon(usedCamera, positionInsideViewport0to1, iconType, color, sizeOfIcon_relToViewportHeight, text_inclGlobalMarkupTags, zRotationDegCC, linesWidth_relToViewportHeight, drawPointerIfOffscreen, iconIsMirroredHorizontally, 0.0f);
|
||||
break;
|
||||
case ShapeDrawer2D.ShapeType.triangle:
|
||||
UtilitiesDXXL_Shapes.Set_shapeFillDensity_reversible(shapeFillDensity);
|
||||
UtilitiesDXXL_Screenspace.DrawShape(usedCamera, positionInsideViewport0to1, DrawShapes.Shape2DType.triangle, color, color, width_relToViewportHeight_initialValue01, height_relToViewportHeight_initialValue01, zRotationDegCC, linesWidth_relToViewportHeight, text_inclGlobalMarkupTags, lineStyle, stylePatternScaleFactor, fillStyle, drawPointerIfOffscreen, addTextForOutsideDistance_toOffscreenPointer, 0.0f, 1.0f, null, drawHullEdgeLines_forScreenEncasingShapes);
|
||||
UtilitiesDXXL_Shapes.Reverse_shapeFillDensity();
|
||||
break;
|
||||
case ShapeDrawer2D.ShapeType.square:
|
||||
UtilitiesDXXL_Shapes.Set_shapeFillDensity_reversible(shapeFillDensity);
|
||||
UtilitiesDXXL_Screenspace.DrawShape(usedCamera, positionInsideViewport0to1, DrawShapes.Shape2DType.square, color, color, width_relToViewportHeight_initialValue01, height_relToViewportHeight_initialValue01, zRotationDegCC, linesWidth_relToViewportHeight, text_inclGlobalMarkupTags, lineStyle, stylePatternScaleFactor, fillStyle, drawPointerIfOffscreen, addTextForOutsideDistance_toOffscreenPointer, 0.0f, 1.0f, null, drawHullEdgeLines_forScreenEncasingShapes);
|
||||
UtilitiesDXXL_Shapes.Reverse_shapeFillDensity();
|
||||
break;
|
||||
case ShapeDrawer2D.ShapeType.pentagon:
|
||||
UtilitiesDXXL_Shapes.Set_shapeFillDensity_reversible(shapeFillDensity);
|
||||
UtilitiesDXXL_Screenspace.DrawShape(usedCamera, positionInsideViewport0to1, DrawShapes.Shape2DType.pentagon, color, color, width_relToViewportHeight_initialValue01, height_relToViewportHeight_initialValue01, zRotationDegCC, linesWidth_relToViewportHeight, text_inclGlobalMarkupTags, lineStyle, stylePatternScaleFactor, fillStyle, drawPointerIfOffscreen, addTextForOutsideDistance_toOffscreenPointer, 0.0f, 1.0f, null, drawHullEdgeLines_forScreenEncasingShapes);
|
||||
UtilitiesDXXL_Shapes.Reverse_shapeFillDensity();
|
||||
break;
|
||||
case ShapeDrawer2D.ShapeType.hexagon:
|
||||
UtilitiesDXXL_Shapes.Set_shapeFillDensity_reversible(shapeFillDensity);
|
||||
UtilitiesDXXL_Screenspace.DrawShape(usedCamera, positionInsideViewport0to1, DrawShapes.Shape2DType.hexagon, color, color, width_relToViewportHeight_initialValue01, height_relToViewportHeight_initialValue01, zRotationDegCC, linesWidth_relToViewportHeight, text_inclGlobalMarkupTags, lineStyle, stylePatternScaleFactor, fillStyle, drawPointerIfOffscreen, addTextForOutsideDistance_toOffscreenPointer, 0.0f, 1.0f, null, drawHullEdgeLines_forScreenEncasingShapes);
|
||||
UtilitiesDXXL_Shapes.Reverse_shapeFillDensity();
|
||||
break;
|
||||
case ShapeDrawer2D.ShapeType.septagon:
|
||||
UtilitiesDXXL_Shapes.Set_shapeFillDensity_reversible(shapeFillDensity);
|
||||
UtilitiesDXXL_Screenspace.DrawShape(usedCamera, positionInsideViewport0to1, DrawShapes.Shape2DType.septagon, color, color, width_relToViewportHeight_initialValue01, height_relToViewportHeight_initialValue01, zRotationDegCC, linesWidth_relToViewportHeight, text_inclGlobalMarkupTags, lineStyle, stylePatternScaleFactor, fillStyle, drawPointerIfOffscreen, addTextForOutsideDistance_toOffscreenPointer, 0.0f, 1.0f, null, drawHullEdgeLines_forScreenEncasingShapes);
|
||||
UtilitiesDXXL_Shapes.Reverse_shapeFillDensity();
|
||||
break;
|
||||
case ShapeDrawer2D.ShapeType.octagon:
|
||||
UtilitiesDXXL_Shapes.Set_shapeFillDensity_reversible(shapeFillDensity);
|
||||
UtilitiesDXXL_Screenspace.DrawShape(usedCamera, positionInsideViewport0to1, DrawShapes.Shape2DType.octagon, color, color, width_relToViewportHeight_initialValue01, height_relToViewportHeight_initialValue01, zRotationDegCC, linesWidth_relToViewportHeight, text_inclGlobalMarkupTags, lineStyle, stylePatternScaleFactor, fillStyle, drawPointerIfOffscreen, addTextForOutsideDistance_toOffscreenPointer, 0.0f, 1.0f, null, drawHullEdgeLines_forScreenEncasingShapes);
|
||||
UtilitiesDXXL_Shapes.Reverse_shapeFillDensity();
|
||||
break;
|
||||
case ShapeDrawer2D.ShapeType.decagon:
|
||||
UtilitiesDXXL_Shapes.Set_shapeFillDensity_reversible(shapeFillDensity);
|
||||
UtilitiesDXXL_Screenspace.DrawShape(usedCamera, positionInsideViewport0to1, DrawShapes.Shape2DType.decagon, color, color, width_relToViewportHeight_initialValue01, height_relToViewportHeight_initialValue01, zRotationDegCC, linesWidth_relToViewportHeight, text_inclGlobalMarkupTags, lineStyle, stylePatternScaleFactor, fillStyle, drawPointerIfOffscreen, addTextForOutsideDistance_toOffscreenPointer, 0.0f, 1.0f, null, drawHullEdgeLines_forScreenEncasingShapes);
|
||||
UtilitiesDXXL_Shapes.Reverse_shapeFillDensity();
|
||||
break;
|
||||
case ShapeDrawer2D.ShapeType.dot:
|
||||
DrawScreenspace.Dot(usedCamera, positionInsideViewport0to1, radius_relToViewportHeight, color, text_inclGlobalMarkupTags, dotDensity, drawPointerIfOffscreen, 0.0f);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
UtilitiesDXXL_LineStyles.logWarningToConsole_forTooSmallPatternScaleFactor = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5fdf0d5a1f81dc4eb379bd7b5e26d61
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,135 @@
|
||||
namespace DrawXXL
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
[HelpURL("https://www.symphonygames.net/drawxxldocumentation/index.html")]
|
||||
[AddComponentMenu("Xeric Library/DebugDrawLibrary/Screenspace/Tag Drawer Screenspace")]
|
||||
[DefaultExecutionOrder(31000)] //negative numers are early, positive numbers are late. Range is till 32000 to both negative and positive direction.
|
||||
public class TagDrawerScreenspace : VisualizerScreenspaceParent
|
||||
{
|
||||
public enum TaggedPositionType { positionOnViewport, aGameobject, multipleGameobjects };
|
||||
[SerializeField] TaggedPositionType taggedPositionType = TaggedPositionType.positionOnViewport;
|
||||
public enum PointerDirectionSpecificationType { fixedAngle, vanishingPointPosition };
|
||||
[SerializeField] PointerDirectionSpecificationType pointerDirectionSpecificationType = PointerDirectionSpecificationType.vanishingPointPosition;
|
||||
|
||||
//both types:
|
||||
[SerializeField] [Range(0.0f, 0.2f)] float linesWidth_relToViewportHeight = 0.0f;
|
||||
[SerializeField] Color colorForText = DrawBasics.defaultColor;
|
||||
[SerializeField] bool drawPointerIfOffscreen = true;
|
||||
|
||||
//only for "positionOnViewport":
|
||||
[SerializeField] bool forceTextSize = false;
|
||||
[SerializeField] [Range(0.01f, 0.5f)] float forceTextSize_value = 0.1f;
|
||||
[SerializeField] bool skipConeDrawing = false;
|
||||
[SerializeField] bool addTextForOutsideDistance_toOffscreenPointer = true;
|
||||
static float default_textOffsetDistance_relToViewportHeight = 0.2f;
|
||||
[SerializeField] [Range(0.035f, 1.0f)] float textOffsetDistance_relToViewportHeight = default_textOffsetDistance_relToViewportHeight;
|
||||
[SerializeField] [Range(-360f, 360.0f)] float fixedPointerDiretion_angledDegCC = -30.0f;
|
||||
|
||||
//only for "aGameobject":
|
||||
[SerializeField] bool differentBoxColor = false;
|
||||
[SerializeField] Color differentBoxColor_value = UtilitiesDXXL_Colors.violet;
|
||||
[SerializeField] bool encapsulateChildren = true;
|
||||
|
||||
//only for "multipleGameobjects":
|
||||
[SerializeField] InternalDXXL_TaggedScreenspaceObject[] taggedScreenspaceObjects;
|
||||
|
||||
public override void InitializeValues_onceInComponentLifetime()
|
||||
{
|
||||
if (text_exclGlobalMarkupTags == null || text_exclGlobalMarkupTags == "")
|
||||
{
|
||||
text_exclGlobalMarkupTags = "tag text";
|
||||
text_inclGlobalMarkupTags = "tag text";
|
||||
}
|
||||
textSection_isOutfolded = true;
|
||||
positionInsideViewport0to1 = new Vector2(0.35f, 0.35f);
|
||||
positionInsideViewport0to1_v2 = new Vector2(0.5f, 0.5f);
|
||||
}
|
||||
|
||||
public override void InitializeValues_alsoOnPlaymodeEnter_andOnComponentCreatedAsCopy()
|
||||
{
|
||||
TryFetchCamOnThisGO_andDecideScreenspaceDefiningCamera();
|
||||
}
|
||||
|
||||
public override void DrawVisualizedObject()
|
||||
{
|
||||
Camera usedCamera = Get_usedCamera("Tag Drawer Screenspace Component");
|
||||
if (usedCamera != null)
|
||||
{
|
||||
float used_relTextSizeScaling;
|
||||
switch (taggedPositionType)
|
||||
{
|
||||
case TaggedPositionType.positionOnViewport:
|
||||
used_relTextSizeScaling = Get_used_relTextSizeScaling();
|
||||
Get_vanishingPointSpecs(out Vector2 textOffsetDir, out Vector2 customTowardsPoint_ofDefaultTextOffsetDir, usedCamera);
|
||||
DrawScreenspace.PointTag(usedCamera, positionInsideViewport0to1, text_inclGlobalMarkupTags, null, colorForText, drawPointerIfOffscreen, linesWidth_relToViewportHeight, textOffsetDistance_relToViewportHeight, textOffsetDir, used_relTextSizeScaling, skipConeDrawing, addTextForOutsideDistance_toOffscreenPointer, 0.0f, customTowardsPoint_ofDefaultTextOffsetDir);
|
||||
break;
|
||||
case TaggedPositionType.aGameobject:
|
||||
Color used_colorForBox = differentBoxColor ? differentBoxColor_value : colorForText;
|
||||
TagAGameobject(usedCamera, partnerGameobject, text_inclGlobalMarkupTags, used_colorForBox);
|
||||
break;
|
||||
case TaggedPositionType.multipleGameobjects:
|
||||
if (taggedScreenspaceObjects != null)
|
||||
{
|
||||
for (int i = 0; i < taggedScreenspaceObjects.Length; i++)
|
||||
{
|
||||
taggedScreenspaceObjects[i].TryUseSeededColorFromGameobjectID();
|
||||
TagAGameobject(usedCamera, taggedScreenspaceObjects[i].gameobject, taggedScreenspaceObjects[i].text, taggedScreenspaceObjects[i].color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TagAGameobject(Camera usedCamera, GameObject gameobjectToTag, string textAtGameobject, Color used_colorForBox)
|
||||
{
|
||||
if (gameobjectToTag != null)
|
||||
{
|
||||
//float used_relTextSizeScaling = forceTextSize_value; //"TagGameObjectScreenspace()" uses a fixed text size indepentent of the box size. So an "absolute" forceTextSize_value can be used here as "relative scaler", because "relative" already means "relative to viewport height". And that is an "absolute" size in the sense, that it is "absoulte in viewportSpaceUnits" and not "relative to boxSize/pointerLength".
|
||||
float used_relTextSizeScaling = 1.0f; //In the "aGameobject"-case the text size is not scaled via the "relTextSizeScaling" parameter but via "Text/Style/Size scaling"
|
||||
DrawEngineBasics.TagGameObjectScreenspace(usedCamera, gameobjectToTag, textAtGameobject, colorForText, used_colorForBox, linesWidth_relToViewportHeight, drawPointerIfOffscreen, used_relTextSizeScaling, encapsulateChildren, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
float Get_used_relTextSizeScaling()
|
||||
{
|
||||
//This relative scaler is used to actually produce an "absolute" text size ("absoulte in viewportSpaceUnits")
|
||||
if (forceTextSize)
|
||||
{
|
||||
if (UtilitiesDXXL_Math.ApproximatelyZero(textOffsetDistance_relToViewportHeight) == false)
|
||||
{
|
||||
return ((forceTextSize_value * default_textOffsetDistance_relToViewportHeight) / (textOffsetDistance_relToViewportHeight * UtilitiesDXXL_DrawBasics.pointTagsTextSize_relToOffset));
|
||||
}
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
void Get_vanishingPointSpecs(out Vector2 textOffsetDir, out Vector2 customTowardsPoint_ofDefaultTextOffsetDir, Camera usedCamera)
|
||||
{
|
||||
switch (pointerDirectionSpecificationType)
|
||||
{
|
||||
case PointerDirectionSpecificationType.fixedAngle:
|
||||
Quaternion rotation_fromUp = Quaternion.AngleAxis(fixedPointerDiretion_angledDegCC, Vector3.forward);
|
||||
Vector3 textOffsetDir_asV3 = rotation_fromUp * Vector3.up;
|
||||
Vector2 textOffsetDir_inUnwarpedSpace = (new Vector2(textOffsetDir_asV3.x, textOffsetDir_asV3.y));
|
||||
Vector2 textOffsetDir_inWarpedSpace = DrawScreenspace.DirectionInUnitsOfUnwarpedSpace_to_sameLookingDirectionInUnitsOfWarpedSpace(textOffsetDir_inUnwarpedSpace, usedCamera);
|
||||
textOffsetDir = textOffsetDir_inWarpedSpace;
|
||||
customTowardsPoint_ofDefaultTextOffsetDir = default(Vector2);
|
||||
break;
|
||||
case PointerDirectionSpecificationType.vanishingPointPosition:
|
||||
textOffsetDir = default(Vector2);
|
||||
customTowardsPoint_ofDefaultTextOffsetDir = positionInsideViewport0to1_v2;
|
||||
break;
|
||||
default:
|
||||
textOffsetDir = default(Vector2);
|
||||
customTowardsPoint_ofDefaultTextOffsetDir = default(Vector2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cba906df682cf2542baabe02418016ed
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,109 @@
|
||||
namespace DrawXXL
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
[HelpURL("https://www.symphonygames.net/drawxxldocumentation/index.html")]
|
||||
[AddComponentMenu("Xeric Library/DebugDrawLibrary/Screenspace/Text Drawer Screenspace")]
|
||||
[DefaultExecutionOrder(31000)] //negative numers are early, positive numbers are late. Range is till 32000 to both negative and positive direction.
|
||||
public class TextDrawerScreenspace : VisualizerScreenspaceParent
|
||||
{
|
||||
[SerializeField] Color color = DrawBasics.defaultColor;
|
||||
[SerializeField] [Range(0.001f, 1.0f)] float size_relToViewportHeight = 0.025f;
|
||||
[SerializeField] DrawText.TextAnchorDXXL textAnchor = DrawText.TextAnchorDXXL.LowerLeft;
|
||||
[SerializeField] public bool enclosingBox_isOutfolded = false; //is only "public" to silence the compiler warning saying that it is "never used". The compiler doesn't know that it is used via serialization.
|
||||
[SerializeField] DrawBasics.LineStyle enclosingBoxLineStyle = DrawBasics.LineStyle.invisible;
|
||||
[SerializeField] float enclosingBox_lineWidth_relToTextSize = 0.0f;
|
||||
[SerializeField] float enclosingBox_paddingSize_relToTextSize = 0.0f;
|
||||
[SerializeField] bool autoLineBreakAtScreenBorder = true;
|
||||
[SerializeField] bool autoFlipTextToPreventUpsideDown = true;
|
||||
|
||||
[SerializeField] public bool forceTextEnlargementToThisMinWidth_relToViewportWidth_isOutfolded = false; //is only "public" to silence the compiler warning saying that it is "never used". The compiler doesn't know that it is used via serialization.
|
||||
[SerializeField] bool forceTextEnlargementToThisMinWidth_relToViewportWidth = false;
|
||||
[SerializeField] [Range(0.003f, 2.0f)] float forceTextEnlargementToThisMinWidth_relToViewportWidth_value = 0.1f;
|
||||
|
||||
[SerializeField] public bool forceRestrictTextSizeToThisMaxTextWidth_relToViewportWidth_isOutfolded = false; //is only "public" to silence the compiler warning saying that it is "never used". The compiler doesn't know that it is used via serialization.
|
||||
[SerializeField] bool forceRestrictTextSizeToThisMaxTextWidth_relToViewportWidth = false;
|
||||
[SerializeField] [Range(0.003f, 2.0f)] float forceRestrictTextSizeToThisMaxTextWidth_relToViewportWidth_value = 0.5f;
|
||||
|
||||
[SerializeField] public bool autoLineBreakWidth_relToViewportWidth_isOutfolded = false; //is only "public" to silence the compiler warning saying that it is "never used". The compiler doesn't know that it is used via serialization.
|
||||
[SerializeField] bool autoLineBreakWidth_relToViewportWidth = false;
|
||||
[SerializeField] [Range(0.003f, 2.0f)] float autoLineBreakWidth_relToViewportWidth_value = 0.5f;
|
||||
|
||||
public override void InitializeValues_onceInComponentLifetime()
|
||||
{
|
||||
if (text_exclGlobalMarkupTags == null || text_exclGlobalMarkupTags == "")
|
||||
{
|
||||
text_exclGlobalMarkupTags = "text to draw";
|
||||
text_inclGlobalMarkupTags = "text to draw";
|
||||
}
|
||||
textSection_isOutfolded = true;
|
||||
|
||||
customVector2Configs[0].picker_isOutfolded = false;
|
||||
customVector2Configs[0].source = CustomVector2Source.rotationAroundZStartingFromRight;
|
||||
customVector2Configs[0].clipboardForManualInput = Vector2.right;
|
||||
customVector2Configs[0].vectorInterpretation = VectorInterpretation.globalSpace;
|
||||
}
|
||||
|
||||
public override void InitializeValues_alsoOnPlaymodeEnter_andOnComponentCreatedAsCopy()
|
||||
{
|
||||
TryFetchCamOnThisGO_andDecideScreenspaceDefiningCamera();
|
||||
}
|
||||
|
||||
public override void DrawVisualizedObject()
|
||||
{
|
||||
Camera usedCamera = Get_usedCamera("Text Drawer Screenspace Component");
|
||||
if (usedCamera != null)
|
||||
{
|
||||
if (text_inclGlobalMarkupTags != null && text_inclGlobalMarkupTags != "")
|
||||
{
|
||||
if (UtilitiesDXXL_Math.ApproximatelyZero(size_relToViewportHeight) == false)
|
||||
{
|
||||
float used_forceTextEnlargementToThisMinWidth_relToViewportWidth_value = Get_used_forceTextEnlargementToThisMinWidth_relToViewportWidth_value();
|
||||
float used_forceRestrictTextSizeToThisMaxTextWidth_relToViewportWidth_value = Get_used_forceRestrictTextSizeToThisMaxTextWidth_relToViewportWidth_value();
|
||||
float used_autoLineBreakWidth_relToViewportWidth_value = Get_used_autoLineBreakWidth_relToViewportWidth_value();
|
||||
Vector2 textDir = Get_customVector2_1_inGlobalSpaceUnits();
|
||||
UtilitiesDXXL_Text.WriteScreenSpace(usedCamera, text_inclGlobalMarkupTags, positionInsideViewport0to1, color, size_relToViewportHeight, textDir, textAnchor, enclosingBoxLineStyle, enclosingBox_lineWidth_relToTextSize, enclosingBox_paddingSize_relToTextSize, used_forceTextEnlargementToThisMinWidth_relToViewportWidth_value, used_forceRestrictTextSizeToThisMaxTextWidth_relToViewportWidth_value, autoLineBreakAtScreenBorder, used_autoLineBreakWidth_relToViewportWidth_value, autoFlipTextToPreventUpsideDown, 0.0f, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float Get_used_forceTextEnlargementToThisMinWidth_relToViewportWidth_value()
|
||||
{
|
||||
if (forceTextEnlargementToThisMinWidth_relToViewportWidth)
|
||||
{
|
||||
return forceTextEnlargementToThisMinWidth_relToViewportWidth_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public float Get_used_forceRestrictTextSizeToThisMaxTextWidth_relToViewportWidth_value()
|
||||
{
|
||||
if (forceRestrictTextSizeToThisMaxTextWidth_relToViewportWidth)
|
||||
{
|
||||
return forceRestrictTextSizeToThisMaxTextWidth_relToViewportWidth_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public float Get_used_autoLineBreakWidth_relToViewportWidth_value()
|
||||
{
|
||||
if (autoLineBreakWidth_relToViewportWidth)
|
||||
{
|
||||
return autoLineBreakWidth_relToViewportWidth_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9dd419436cc09154795ba70b6a3b5398
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user