更新到0.6.0.2
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b9700223156c2d4b9c92bf7c0f208b0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,160 @@
|
||||
namespace DrawXXL
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
[HelpURL("https://www.symphonygames.net/drawxxldocumentation/index.html")]
|
||||
[AddComponentMenu("Xeric Library/DebugDrawLibrary/2D/Line Drawer 2D")]
|
||||
public class LineDrawer2D : LineDrawer
|
||||
{
|
||||
public override void InitializeValues_onceInComponentLifetime()
|
||||
{
|
||||
TrySetTextToEmptyString();
|
||||
|
||||
customVector2Configs[0].picker_isOutfolded = true;
|
||||
customVector2Configs[0].source = CustomVector2Source.transformsRight;
|
||||
customVector2Configs[0].clipboardForManualInput = Vector2.right;
|
||||
customVector2Configs[0].vectorInterpretation = VectorInterpretation.globalSpace;
|
||||
|
||||
customVector2Configs[2].source = CustomVector2Source.manualInput;
|
||||
customVector2Configs[2].clipboardForManualInput = Vector2.zero;
|
||||
customVector2Configs[2].vectorInterpretation = VectorInterpretation.globalSpace;
|
||||
|
||||
customVector2Configs[3].source = CustomVector2Source.manualInput;
|
||||
customVector2Configs[3].clipboardForManualInput = Vector2.right;
|
||||
customVector2Configs[3].vectorInterpretation = VectorInterpretation.globalSpace;
|
||||
|
||||
endPlates_size = 0.1f; //is initially disabled due to "endPlatesConfig"
|
||||
lineStyle_underTension = DrawBasics.LineStyle.sine;
|
||||
}
|
||||
|
||||
public override void DrawVisualizedObject()
|
||||
{
|
||||
float used_enlargeSmallTextToThisMinTextSize_value = enlargeSmallTextToThisMinTextSize ? enlargeSmallTextToThisMinTextSize_value : 0.0f;
|
||||
float used_endPlates_size = 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);
|
||||
|
||||
switch (lineType)
|
||||
{
|
||||
case LineType.standardLine:
|
||||
if (useDifferentEndColor)
|
||||
{
|
||||
precedingLineAnimationProgress = LineFrom_fadeableAnimSpeed_2D.InternalDraw_withColorFade(lineStartPosition, vector_fromLineStart_toLineEnd, startColor, endColor, lineWidth, text_inclGlobalMarkupTags, lineStyle, GetZPos_global_for2D(), stylePatternScaleFactor, animationSpeed, precedingLineAnimationProgress, used_endPlates_size, alphaFadeOutLength_0to1, used_enlargeSmallTextToThisMinTextSize_value, 0.0f, hiddenByNearerObjects, skipPatternEnlargementForLongLines, skipPatternEnlargementForShortLines);
|
||||
}
|
||||
else
|
||||
{
|
||||
precedingLineAnimationProgress = LineFrom_fadeableAnimSpeed_2D.InternalDraw(lineStartPosition, vector_fromLineStart_toLineEnd, startColor, lineWidth, text_inclGlobalMarkupTags, lineStyle, GetZPos_global_for2D(), stylePatternScaleFactor, animationSpeed, precedingLineAnimationProgress, used_endPlates_size, alphaFadeOutLength_0to1, used_enlargeSmallTextToThisMinTextSize_value, 0.0f, hiddenByNearerObjects, skipPatternEnlargementForLongLines, skipPatternEnlargementForShortLines);
|
||||
}
|
||||
break;
|
||||
case LineType.vector:
|
||||
switch (conesConfig)
|
||||
{
|
||||
case ConesConfig.bothSides:
|
||||
DrawBasics2D.VectorFrom(lineStartPosition, vector_fromLineStart_toLineEnd, startColor, lineWidth, text_inclGlobalMarkupTags, coneLength_forStraightVectors, true, GetZPos_global_for2D(), addNormalizedMarkingText, used_enlargeSmallTextToThisMinTextSize_value, writeComponentValuesAsText, used_endPlates_size, 0.0f, hiddenByNearerObjects);
|
||||
break;
|
||||
case ConesConfig.onlyAtStart:
|
||||
DrawBasics2D.VectorTo(-vector_fromLineStart_toLineEnd, lineStartPosition, startColor, lineWidth, text_inclGlobalMarkupTags, coneLength_forStraightVectors, false, GetZPos_global_for2D(), addNormalizedMarkingText, used_enlargeSmallTextToThisMinTextSize_value, writeComponentValuesAsText, used_endPlates_size, 0.0f, hiddenByNearerObjects);
|
||||
break;
|
||||
case ConesConfig.onlyAtEnd:
|
||||
DrawBasics2D.VectorFrom(lineStartPosition, vector_fromLineStart_toLineEnd, startColor, lineWidth, text_inclGlobalMarkupTags, coneLength_forStraightVectors, false, GetZPos_global_for2D(), addNormalizedMarkingText, used_enlargeSmallTextToThisMinTextSize_value, writeComponentValuesAsText, used_endPlates_size, 0.0f, hiddenByNearerObjects);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case LineType.vectorWithExtention:
|
||||
float used_forceFixedConeLength_value = forceFixedConeLength ? forceFixedConeLength_value : 0.0f;
|
||||
DrawEngineBasics.RayLineExtended2D(lineStartPosition, vector_fromLineStart_toLineEnd, startColor, lineWidth, text_inclGlobalMarkupTags, GetZPos_global_for2D(), used_forceFixedConeLength_value, addNormalizedMarkingText, used_enlargeSmallTextToThisMinTextSize_value, extentionLength, 0.0f, hiddenByNearerObjects);
|
||||
break;
|
||||
case 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.
|
||||
DrawBasics2D.BlinkingRay(lineStartPosition, vector_fromLineStart_toLineEnd, startColor, used_blinkDurationInSec, lineWidth, text_inclGlobalMarkupTags, lineStyle, blinkColor, GetZPos_global_for2D(), stylePatternScaleFactor, used_endPlates_size, alphaFadeOutLength_0to1, used_enlargeSmallTextToThisMinTextSize_value, 0.0f, hiddenByNearerObjects, skipPatternEnlargementForLongLines, skipPatternEnlargementForShortLines);
|
||||
break;
|
||||
case LineType.lineUnderTension:
|
||||
DrawBasics2D.RayUnderTension(lineStartPosition, vector_fromLineStart_toLineEnd, relaxedLength, relaxedColor, lineStyle_underTension, stretchFactor_forStretchedTensionColor, color_forStretchedTension, stretchFactor_forSqueezedTensionColor, color_forSqueezedTension, lineWidth, text_inclGlobalMarkupTags, alphaOfReferenceLengthDisplay, GetZPos_global_for2D(), stylePatternScaleFactor, used_endPlates_size, used_enlargeSmallTextToThisMinTextSize_value, 0.0f, hiddenByNearerObjects, skipPatternEnlargementForLongLines, skipPatternEnlargementForShortLines);
|
||||
break;
|
||||
case LineType.movingArrowsLine:
|
||||
precedingLineAnimationProgress = MovingArrowsRay_fadeableAnimSpeed_2D.InternalDraw(lineStartPosition, vector_fromLineStart_toLineEnd, startColor, lineWidth_ofMovingArrowsLine, distanceBetweenArrows, lengthOfArrows, text_inclGlobalMarkupTags, GetZPos_global_for2D(), animationSpeed_ofMovingArrowsLine, precedingLineAnimationProgress, backwardAnimationFlipsArrowDirection, used_endPlates_size, used_enlargeSmallTextToThisMinTextSize_value, 0.0f, hiddenByNearerObjects);
|
||||
break;
|
||||
case LineType.lineWithAlternatingColors:
|
||||
precedingLineAnimationProgress = RayWithAlternatingColors_fadeableAnimSpeed_2D.InternalDraw(lineStartPosition, vector_fromLineStart_toLineEnd, startColor, alternatingColor, lineWidth, lengthOfStripes, text_inclGlobalMarkupTags, GetZPos_global_for2D(), animationSpeed, precedingLineAnimationProgress, used_endPlates_size, alphaFadeOutLength_0to1, used_enlargeSmallTextToThisMinTextSize_value, 0.0f, hiddenByNearerObjects, skipPatternEnlargementForLongLines, skipPatternEnlargementForShortLines);
|
||||
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)
|
||||
{
|
||||
Vector2 lineEndPosition;
|
||||
switch (lineDefinitionMode)
|
||||
{
|
||||
case LineDefinitionMode.startPositionAndEndPosition:
|
||||
lineStartPosition = GetLineStartPosition_fromDefineStartPosSection();
|
||||
lineEndPosition = GetLineEndPosition_fromDefineEndPosSection();
|
||||
vector_fromLineStart_toLineEnd = lineEndPosition - lineStartPosition;
|
||||
break;
|
||||
case LineDefinitionMode.startPositionAndDirectionVectorToEndPosition:
|
||||
lineStartPosition = GetLineStartPosition_fromDefineStartPosSection();
|
||||
vector_fromLineStart_toLineEnd = Get_customVector2_1_inGlobalSpaceUnits();
|
||||
break;
|
||||
case LineDefinitionMode.endPositionAndDirectionVectorToIt:
|
||||
lineEndPosition = GetLineEndPosition_fromDefineEndPosSection();
|
||||
vector_fromLineStart_toLineEnd = Get_customVector2_1_inGlobalSpaceUnits();
|
||||
lineStartPosition = lineEndPosition - vector_fromLineStart_toLineEnd;
|
||||
break;
|
||||
default:
|
||||
lineStartPosition = Vector2.zero;
|
||||
vector_fromLineStart_toLineEnd = Vector2.right;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Vector2 GetLineStartPosition_fromDefineStartPosSection()
|
||||
{
|
||||
switch (positionDefinitionOption_ofStartPos)
|
||||
{
|
||||
case PositionDefinitionOption.positionOfThisGameobjectPlusOffset:
|
||||
return GetDrawPos2D_global();
|
||||
case PositionDefinitionOption.positionOfOtherGameobjectPlusOffset:
|
||||
bool theSpaceForTransformingThePartnerLocalOffsetValue_isTakenFromThePartnerGameobject_notFromThisGameobject = (coordinateSpaceForLocalOffsetOnOtherGameobject_forStartPos == CoordinateSpaceForLocalOffset.useLocalSpaceDefinedByTransformOnOtherGameobject);
|
||||
return GetDrawPos2D_ofPartnerGameobject_global(theSpaceForTransformingThePartnerLocalOffsetValue_isTakenFromThePartnerGameobject_notFromThisGameobject);
|
||||
case PositionDefinitionOption.chooseFree:
|
||||
return Get_customVector2_3_inGlobalSpaceUnits();
|
||||
default:
|
||||
return Vector2.zero;
|
||||
}
|
||||
}
|
||||
|
||||
Vector2 GetLineEndPosition_fromDefineEndPosSection()
|
||||
{
|
||||
switch (positionDefinitionOption_ofEndPos)
|
||||
{
|
||||
case PositionDefinitionOption.positionOfThisGameobjectPlusOffset:
|
||||
return GetDrawPos2D_global_independentAlternativeValue();
|
||||
case PositionDefinitionOption.positionOfOtherGameobjectPlusOffset:
|
||||
bool theSpaceForTransformingThePartnerLocalOffsetValue_isTakenFromThePartnerGameobject_notFromThisGameobject = (coordinateSpaceForLocalOffsetOnOtherGameobject_forEndPos == CoordinateSpaceForLocalOffset.useLocalSpaceDefinedByTransformOnOtherGameobject);
|
||||
return GetDrawPos2D_ofPartnerGameobject_global_independentAlternativeValue(theSpaceForTransformingThePartnerLocalOffsetValue_isTakenFromThePartnerGameobject_notFromThisGameobject);
|
||||
case PositionDefinitionOption.chooseFree:
|
||||
return Get_customVector2_4_inGlobalSpaceUnits();
|
||||
default:
|
||||
return Vector2.one;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetLineLength()
|
||||
{
|
||||
GetLineStartPosAndDirection(out Vector2 lineStartPosition, out Vector2 vector_fromLineStart_toLineEnd);
|
||||
return vector_fromLineStart_toLineEnd.magnitude;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7faa130aef499634f8de3d45f22be81f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,164 @@
|
||||
namespace DrawXXL
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
[HelpURL("https://www.symphonygames.net/drawxxldocumentation/index.html")]
|
||||
[AddComponentMenu("Xeric Library/DebugDrawLibrary/2D/Measurement Visualizer 2D")]
|
||||
[DefaultExecutionOrder(31000)] //negative numers are early, positive numbers are late. Range is till 32000 to both negative and positive direction.
|
||||
public class MeasurementVisualizer2D : VisualizerParent
|
||||
{
|
||||
public enum MeasurementType { distanceBetweenPoints, distanceThresholdBetweenPoints, distanceFromPointToLine, angleBetweenVectors, angleFromLineToLine };
|
||||
[SerializeField] MeasurementType measurementType = MeasurementType.distanceBetweenPoints;
|
||||
|
||||
[SerializeField] Color color1 = DrawMeasurements.defaultColor1;
|
||||
[SerializeField] Color color2 = DrawMeasurements.defaultColor2;
|
||||
[SerializeField] public bool appearanceBlock_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 float measuredResultValue; //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] Color color = DrawBasics.defaultColor;
|
||||
[SerializeField] float linesWidth = 0.0f;
|
||||
[SerializeField] float enlargeSmallTextToThisMinTextSize = 0.005f;
|
||||
[SerializeField] bool addTextForAlternativeAngleUnit = true;
|
||||
[SerializeField] MeasurementVisualizer.AngleUnit angleUnitToDisplay = MeasurementVisualizer.AngleUnit.degree;
|
||||
[SerializeField] float forceRadius_value = 1.0f;
|
||||
[SerializeField] bool useReflexAngleOver180deg = false;
|
||||
[SerializeField] bool drawBoundaryLines = true;
|
||||
[SerializeField] bool returnObtuseAngleOver90deg = false;
|
||||
[SerializeField] string name_ofGeoObject1 = null;
|
||||
[SerializeField] string name_ofGeoObject2 = null;
|
||||
[SerializeField] MeasurementVisualizer.DistanceThresholdType distanceThresholdType = MeasurementVisualizer.DistanceThresholdType.one;
|
||||
[SerializeField] MeasurementVisualizer.PointerConfigOfAngleBetweenVectors pointerConfigOfAngleBetweenVectors = MeasurementVisualizer.PointerConfigOfAngleBetweenVectors.atBothEnds;
|
||||
[SerializeField] float minimumLineLength_forDistancePointToLine = DrawMeasurements2D.minimumLineLength_forDistancePointToLine;
|
||||
[SerializeField] float minimumLineLength_forAngleLineToLine = DrawMeasurements2D.minimumLineLength_forAngleLineToLine;
|
||||
|
||||
//only for distanceThreshold:
|
||||
[SerializeField] float smallerThresholdDistance = 1.0f;
|
||||
[SerializeField] float biggerThresholdDistance = 2.0f;
|
||||
[SerializeField] bool displayDistanceAlsoAsText = false;
|
||||
[SerializeField] MeasurementVisualizer.ExactlyOnThresholdBehaviour exactlyOnThresholdBehaviour = MeasurementVisualizer.ExactlyOnThresholdBehaviour.countAsShorterThanThreshold;
|
||||
|
||||
[SerializeField] DrawBasics.LineStyle overwriteStyle_forNear = DrawBasics.LineStyle.electricNoise;
|
||||
[SerializeField] DrawBasics.LineStyle overwriteStyle_forMiddle = DrawBasics.LineStyle.electricImpulses;
|
||||
[SerializeField] DrawBasics.LineStyle overwriteStyle_forFar = DrawBasics.LineStyle.solid;
|
||||
|
||||
[SerializeField] Color overwriteColor_forNear_oneThresholdVersion = UtilitiesDXXL_Colors.red_boolFalse;
|
||||
[SerializeField] Color overwriteColor_forFar_oneThresholdVersion = UtilitiesDXXL_Colors.green_boolTrue;
|
||||
|
||||
[SerializeField] Color overwriteColor_forNear_twoThresholdsVersion = UtilitiesDXXL_Colors.red_lineThresholdFarDistance;
|
||||
[SerializeField] Color overwriteColor_forMiddle_twoThresholdsVersion = UtilitiesDXXL_Colors.orange_lineThresholdMiddleDistance;
|
||||
[SerializeField] Color overwriteColor_forFar_twoThresholdsVersion = UtilitiesDXXL_Colors.green_lineThresholdNearDistance;
|
||||
|
||||
public override void InitializeValues_onceInComponentLifetime()
|
||||
{
|
||||
TrySetTextToEmptyString();
|
||||
endPlates_size = 0.0f;
|
||||
coneLength_forStraightVectors = 0.10f;
|
||||
coneLength_forCircledVectors = 0.13f;
|
||||
drawPosOffset2DSection_isOutfolded = true;
|
||||
drawPosOffset2DSection_ofPartnerGameobject_isOutfolded = true;
|
||||
|
||||
customVector2Configs[0].picker_isOutfolded = true;
|
||||
customVector2Configs[0].source = CustomVector2Source.transformsRight;
|
||||
customVector2Configs[0].clipboardForManualInput = Vector2.right;
|
||||
customVector2Configs[0].vectorInterpretation = VectorInterpretation.globalSpace;
|
||||
|
||||
customVector2Configs[1].picker_isOutfolded = true;
|
||||
customVector2Configs[1].source = CustomVector2Source.manualInput;
|
||||
customVector2Configs[1].clipboardForManualInput = Vector2.one;
|
||||
customVector2Configs[1].vectorInterpretation = VectorInterpretation.globalSpace;
|
||||
|
||||
customVector2Configs[2].picker_isOutfolded = true;
|
||||
customVector2Configs[2].source = CustomVector2Source.transformsRight;
|
||||
customVector2Configs[2].clipboardForManualInput = Vector2.one;
|
||||
customVector2Configs[2].vectorInterpretation = VectorInterpretation.globalSpace;
|
||||
|
||||
customVector2ofPartnerGameobject_picker_isOutfolded = true;
|
||||
source_ofCustomVector2ofPartnerGameobject = CustomVector2Source.transformsRight;
|
||||
customVector2ofPartnerGameobject_clipboardForManualInput = Vector2.one;
|
||||
vectorInterpretation_ofCustomVector2ofPartnerGameobject = VectorInterpretation.globalSpace;
|
||||
}
|
||||
|
||||
public override void DrawVisualizedObject()
|
||||
{
|
||||
UtilitiesDXXL_Measurements.Set_defaultColor1_reversible(color1);
|
||||
UtilitiesDXXL_Measurements.Set_defaultColor2_reversible(color2);
|
||||
switch (measurementType)
|
||||
{
|
||||
case MeasurementType.distanceBetweenPoints:
|
||||
UtilitiesDXXL_DrawBasics.Set_coneLength_interpretation_forStraightVectors_reversible(coneLength_interpretation_forStraightVectors);
|
||||
measuredResultValue = DrawMeasurements2D.Distance(GetDrawPos2D_global(), GetDrawPos2D_ofPartnerGameobject_global(), color, linesWidth, text_inclGlobalMarkupTags, GetZPos_global_for2D(), coneLength_forStraightVectors, enlargeSmallTextToThisMinTextSize, 0.0f, hiddenByNearerObjects);
|
||||
UtilitiesDXXL_DrawBasics.Reverse_coneLength_interpretation_forStraightVectors();
|
||||
break;
|
||||
case MeasurementType.distanceThresholdBetweenPoints:
|
||||
switch (distanceThresholdType)
|
||||
{
|
||||
case MeasurementVisualizer.DistanceThresholdType.one:
|
||||
UtilitiesDXXL_DrawBasics.Set_endPlates_sizeInterpretation_reversible(endPlates_sizeInterpretation);
|
||||
DrawMeasurements2D.DistanceThreshold(GetDrawPos2D_global(), GetDrawPos2D_ofPartnerGameobject_global(), smallerThresholdDistance, text_inclGlobalMarkupTags, displayDistanceAlsoAsText, linesWidth, GetZPos_global_for2D(), ExactlyThresholdLength_countsAsShorter(), endPlates_size, overwriteStyle_forNear, overwriteStyle_forFar, overwriteColor_forNear_oneThresholdVersion, overwriteColor_forFar_oneThresholdVersion, enlargeSmallTextToThisMinTextSize, 0.0f, hiddenByNearerObjects);
|
||||
UtilitiesDXXL_DrawBasics.Reverse_endPlates_sizeInterpretation();
|
||||
break;
|
||||
case MeasurementVisualizer.DistanceThresholdType.two:
|
||||
UtilitiesDXXL_DrawBasics.Set_endPlates_sizeInterpretation_reversible(endPlates_sizeInterpretation);
|
||||
DrawMeasurements2D.DistanceThresholds(GetDrawPos2D_global(), GetDrawPos2D_ofPartnerGameobject_global(), smallerThresholdDistance, biggerThresholdDistance, text_inclGlobalMarkupTags, displayDistanceAlsoAsText, linesWidth, GetZPos_global_for2D(), ExactlyThresholdLength_countsAsShorter(), endPlates_size, overwriteStyle_forNear, overwriteStyle_forMiddle, overwriteStyle_forFar, overwriteColor_forNear_twoThresholdsVersion, overwriteColor_forMiddle_twoThresholdsVersion, overwriteColor_forFar_twoThresholdsVersion, enlargeSmallTextToThisMinTextSize, 0.0f, hiddenByNearerObjects);
|
||||
UtilitiesDXXL_DrawBasics.Reverse_endPlates_sizeInterpretation();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case MeasurementType.distanceFromPointToLine:
|
||||
UtilitiesDXXL_Measurements2D.Set_minimumLineLength_forDistancePointToLine_reversible(minimumLineLength_forDistancePointToLine);
|
||||
UtilitiesDXXL_DrawBasics.Set_coneLength_interpretation_forStraightVectors_reversible(coneLength_interpretation_forStraightVectors);
|
||||
measuredResultValue = DrawMeasurements2D.DistancePointToLine(GetDrawPos2D_global(), GetDrawPos2D_ofPartnerGameobject_global(), Get_customVector2ofPartnerGameobject_inGlobalSpaceUnits(), color, linesWidth, text_inclGlobalMarkupTags, name_ofGeoObject2, GetZPos_global_for2D(), coneLength_forStraightVectors, enlargeSmallTextToThisMinTextSize, 0.0f, hiddenByNearerObjects);
|
||||
UtilitiesDXXL_DrawBasics.Reverse_coneLength_interpretation_forStraightVectors();
|
||||
UtilitiesDXXL_Measurements2D.Reverse_minimumLineLength_forDistancePointToLine();
|
||||
break;
|
||||
case MeasurementType.angleBetweenVectors:
|
||||
switch (pointerConfigOfAngleBetweenVectors)
|
||||
{
|
||||
case MeasurementVisualizer.PointerConfigOfAngleBetweenVectors.atBothEnds:
|
||||
UtilitiesDXXL_DrawBasics.Set_coneLength_interpretation_forCircledVectors_reversible(coneLength_interpretation_forCircledVectors);
|
||||
measuredResultValue = DrawMeasurements2D.AngleSpan(Get_customVector2_1_inGlobalSpaceUnits(), Get_customVector2_2_inGlobalSpaceUnits(), GetDrawPos2D_global_independentAlternativeValue(), color, forceRadius_value, linesWidth, text_inclGlobalMarkupTags, GetZPos_global_for2D(), useReflexAngleOver180deg, DisplayAndReturn_radInsteadOfDeg(), coneLength_forCircledVectors, drawBoundaryLines, addTextForAlternativeAngleUnit, 0.0f, hiddenByNearerObjects);
|
||||
UtilitiesDXXL_DrawBasics.Reverse_coneLength_interpretation_forCircledVectors();
|
||||
break;
|
||||
case MeasurementVisualizer.PointerConfigOfAngleBetweenVectors.onlyAtStart:
|
||||
UtilitiesDXXL_DrawBasics.Set_coneLength_interpretation_forCircledVectors_reversible(coneLength_interpretation_forCircledVectors);
|
||||
measuredResultValue = DrawMeasurements2D.Angle(Get_customVector2_2_inGlobalSpaceUnits(), Get_customVector2_1_inGlobalSpaceUnits(), GetDrawPos2D_global_independentAlternativeValue(), color, forceRadius_value, linesWidth, text_inclGlobalMarkupTags, GetZPos_global_for2D(), useReflexAngleOver180deg, DisplayAndReturn_radInsteadOfDeg(), coneLength_forCircledVectors, drawBoundaryLines, addTextForAlternativeAngleUnit, 0.0f, hiddenByNearerObjects);
|
||||
UtilitiesDXXL_DrawBasics.Reverse_coneLength_interpretation_forCircledVectors();
|
||||
break;
|
||||
case MeasurementVisualizer.PointerConfigOfAngleBetweenVectors.onlyAtEnd:
|
||||
UtilitiesDXXL_DrawBasics.Set_coneLength_interpretation_forCircledVectors_reversible(coneLength_interpretation_forCircledVectors);
|
||||
measuredResultValue = DrawMeasurements2D.Angle(Get_customVector2_1_inGlobalSpaceUnits(), Get_customVector2_2_inGlobalSpaceUnits(), GetDrawPos2D_global_independentAlternativeValue(), color, forceRadius_value, linesWidth, text_inclGlobalMarkupTags, GetZPos_global_for2D(), useReflexAngleOver180deg, DisplayAndReturn_radInsteadOfDeg(), coneLength_forCircledVectors, drawBoundaryLines, addTextForAlternativeAngleUnit, 0.0f, hiddenByNearerObjects);
|
||||
UtilitiesDXXL_DrawBasics.Reverse_coneLength_interpretation_forCircledVectors();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case MeasurementType.angleFromLineToLine:
|
||||
UtilitiesDXXL_Measurements2D.Set_minimumLineLength_forAngleLineToLine_reversible(minimumLineLength_forAngleLineToLine);
|
||||
UtilitiesDXXL_DrawBasics.Set_coneLength_interpretation_forCircledVectors_reversible(coneLength_interpretation_forCircledVectors);
|
||||
measuredResultValue = DrawMeasurements2D.AngleLineToLine(GetDrawPos2D_global(), Get_customVector2_3_inGlobalSpaceUnits(), GetDrawPos2D_ofPartnerGameobject_global(), Get_customVector2ofPartnerGameobject_inGlobalSpaceUnits(), color, linesWidth, text_inclGlobalMarkupTags, name_ofGeoObject1, name_ofGeoObject2, GetZPos_global_for2D(), returnObtuseAngleOver90deg, DisplayAndReturn_radInsteadOfDeg(), coneLength_forCircledVectors, addTextForAlternativeAngleUnit, 0.0f, hiddenByNearerObjects);
|
||||
UtilitiesDXXL_DrawBasics.Reverse_coneLength_interpretation_forCircledVectors();
|
||||
UtilitiesDXXL_Measurements2D.Reverse_minimumLineLength_forAngleLineToLine();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
UtilitiesDXXL_Measurements.Reverse_defaultColor1();
|
||||
UtilitiesDXXL_Measurements.Reverse_defaultColor2();
|
||||
}
|
||||
|
||||
bool DisplayAndReturn_radInsteadOfDeg()
|
||||
{
|
||||
return (angleUnitToDisplay == MeasurementVisualizer.AngleUnit.radians);
|
||||
}
|
||||
|
||||
bool ExactlyThresholdLength_countsAsShorter()
|
||||
{
|
||||
return (exactlyOnThresholdBehaviour == MeasurementVisualizer.ExactlyOnThresholdBehaviour.countAsShorterThanThreshold);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a20ecf25dae628a4db9e03f54e332a15
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,907 @@
|
||||
namespace DrawXXL
|
||||
{
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
[HelpURL("https://www.symphonygames.net/drawxxldocumentation/index.html")]
|
||||
[AddComponentMenu("Xeric Library/DebugDrawLibrary/2D/Physics Visualizer 2D")]
|
||||
[DefaultExecutionOrder(31000)] //negative numers are early, positive numbers are late. Range is till 32000 to both negative and positive direction.
|
||||
public class PhysicsVisualizer2D : VisualizerParent
|
||||
{
|
||||
public enum Shape { collidersOnThisGameobject, box, circle, capsule, rayOrPoint, ray3D };
|
||||
[SerializeField] Shape shape = Shape.collidersOnThisGameobject;
|
||||
|
||||
[SerializeField] CollisionType collisionType = CollisionType.cast;
|
||||
|
||||
[SerializeField] WantedHits wantedHits = WantedHits.all;
|
||||
|
||||
[SerializeField] bool distanceIsInfinityRespToOtherGO = true;
|
||||
[SerializeField] float adjustedDistance = 10.0f;
|
||||
float used_distance;
|
||||
|
||||
[SerializeField] Vector2 sizeScaleFactors_ofCastRespCheckedBox = Vector2.one;
|
||||
[SerializeField] float radiusScaleFactor_ofCastRespCheckedCircle = 0.5f;
|
||||
[SerializeField] Vector2 sizeScaleFactors_ofCastRespCheckedCapsule = new Vector2(0.5f, 1.0f);
|
||||
[SerializeField] CapsuleDirection2D capsuleDirection2D_ofManuallyConstructedCapsuleMeaningNotFromCollider = CapsuleDirection2D.Vertical;
|
||||
public enum ShapeRotationType { transformsRotationPlusOptionalAdditionalRotation, customRotationIndependentFromTransform };
|
||||
[SerializeField] public ShapeRotationType shapeRotationType = ShapeRotationType.transformsRotationPlusOptionalAdditionalRotation;
|
||||
|
||||
[SerializeField] [Range(0.0f, 360.0f)] float rotationAngleOfShape_additionallyToTransformsAngle = 0.0f;
|
||||
|
||||
BoxCollider2D[] boxColliders2D_onThisGameobject;
|
||||
CircleCollider2D[] circleColliders2D_onThisGameobject;
|
||||
CapsuleCollider2D[] capsuleColliders2D_onThisGameobject;
|
||||
[SerializeField] public bool theGameobjectHasACompatibleAndEnabledCollider; //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.
|
||||
List<RaycastHit2D> unusedRaycastHitResults = new List<RaycastHit2D>();
|
||||
List<Collider2D> unusedResultColliders = new List<Collider2D>();
|
||||
|
||||
[SerializeField] public bool otherSettings_isFoldedOut = 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 excludeCollidersOnThisGO = true;
|
||||
[SerializeField] bool excludeCollidersOnParentGOs = true;
|
||||
[SerializeField] bool excludeCollidersOnChildrenGOs = true;
|
||||
|
||||
Collider2D[] allColliders2DOnThisGameobject;
|
||||
List<bool> enabledState_ofAllColliders2DOnThisGO_beforeCurrentDrawOperation = new List<bool>();
|
||||
[SerializeField] public bool aVisualizedBoxCollider2DOnThisComponent_hasANonZeroEdge; //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 aVisualizedBoxCollider2DOnThisComponent_hasAutoTiling; //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.
|
||||
|
||||
Collider2D[] allColliders2DOnThisGameobjectAndOnParents;
|
||||
List<bool> enabledState_ofAllColliders2DOnThisGOPlusParents_beforeCurrentDrawOperation = new List<bool>();
|
||||
List<bool> isOnThisGO_forAllColliders2DOnThisGOPlusParents_beforeCurrentDrawOperation = new List<bool>();
|
||||
|
||||
Collider2D[] allColliders2DOnThisGameobjectAndOnChildren;
|
||||
List<bool> enabledState_ofAllColliders2DOnThisGOPlusChildren_beforeCurrentDrawOperation = new List<bool>();
|
||||
List<bool> isOnThisGO_forAllColliders2DOnThisGOPlusChildren_beforeCurrentDrawOperation = new List<bool>();
|
||||
|
||||
[SerializeField] LayerMask layerMask = Physics2D.DefaultRaycastLayers; //The "Physics2D.DefaultRaycastLayers" already inludes the layer slots that are not yet defined by the users. That means this doesn't have to updated in cases where a user adds a custom defined layer AFTER the creation of this component
|
||||
|
||||
[SerializeField] bool useDepth = false;
|
||||
[SerializeField] float minDepth = Mathf.NegativeInfinity;
|
||||
[SerializeField] float maxDepth = Mathf.Infinity;
|
||||
[SerializeField] bool useOutsideDepth = false;
|
||||
|
||||
[SerializeField] bool useNormalAngle = false;
|
||||
[SerializeField] [Range(0.0f, 360.0f)] float minNormalAngle = 0.0f;
|
||||
[SerializeField] [Range(0.0f, 360.0f)] float maxNormalAngle = 360.0f;
|
||||
[SerializeField] bool useOutsideNormalAngle = false;
|
||||
|
||||
[SerializeField] bool useTriggers = true;
|
||||
[SerializeField] int numberOfFoundHits = 0;
|
||||
|
||||
//DrawPhysics2D' class global settings:
|
||||
[SerializeField] Color colorForNonHittingCasts = DrawPhysics2D.colorForNonHittingCasts;
|
||||
[SerializeField] Color colorForHittingCasts = DrawPhysics2D.colorForHittingCasts;
|
||||
[SerializeField] Color colorForCastLineBeyondHit = DrawPhysics2D.colorForCastLineBeyondHit;
|
||||
[SerializeField] Color colorForCastsHitText = DrawPhysics2D.colorForCastsHitText;
|
||||
[SerializeField] bool doOverwriteColorForCastsHitNormals = false;
|
||||
[SerializeField] Color overwriteColorForCastsHitNormals = UtilitiesDXXL_Physics2D.Get_defaultColor_ofNormal(); //-> not using "DrawPhysics2D.overwriteColorForCastsHitNormals", since this would be the default color that doesn't represent what the user sees as normal color in the Scene
|
||||
[SerializeField] float scaleFactor_forCastHitTextSize = DrawPhysics2D.scaleFactor_forCastHitTextSize;
|
||||
[SerializeField] float castCorridorVisualizerDensity = DrawPhysics2D.castCorridorVisualizerDensity;
|
||||
[SerializeField] bool drawCastNameTag_atCastOrigin = DrawPhysics2D.drawCastNameTag_atCastOrigin;
|
||||
[SerializeField] bool drawCastNameTag_atHitPositions = DrawPhysics2D.drawCastNameTag_atHitPositions;
|
||||
[SerializeField] int maxListedColliders_inOverlapVolumesTextList = DrawPhysics2D.MaxListedColliders_inOverlapVolumesTextList;
|
||||
[SerializeField] int maxOverlapingCollidersWithUntruncatedText = DrawPhysics2D.maxOverlapingCollidersWithUntruncatedText;
|
||||
[SerializeField] [Range(0.001f, 0.2f)] float forcedConstantScreenspaceTextSize_relToScreenHeight_forOverlapResultTexts = 0.01f;
|
||||
[SerializeField] float forcedConstantWorldspaceTextSize_forOverlapResultTexts = 0.1f;
|
||||
[SerializeField] PhysicsVisualizer.SaveDrawnLinesType saveDrawnLinesType = PhysicsVisualizer.Map_visualizationQuality_to_saveDrawnLinesType(DrawPhysics2D.visualizationQuality);
|
||||
[SerializeField] PhysicsVisualizer.OverlapResultTextSizeInterpretation overlapResultTextSizeInterpretation = PhysicsVisualizer.OverlapResultTextSizeInterpretation.relativeToTheSizeOfTheOverlapingPhysicsShape;
|
||||
[SerializeField] bool useCustomDirectionForHitResultText = false;
|
||||
[SerializeField] Vector2 customDirectionForHitResultText = GetInitialValueFor_customDirectionForHitResultText();
|
||||
|
||||
Color colorForNonHittingCasts_before;
|
||||
Color colorForHittingCasts_before;
|
||||
Color colorForCastLineBeyondHit_before;
|
||||
Color colorForCastsHitText_before;
|
||||
Color overwriteColorForCastsHitNormals_before;
|
||||
float scaleFactor_forCastHitTextSize_before;
|
||||
float castCorridorVisualizerDensity_before;
|
||||
DrawPhysics.VisualizationQuality visualizationQuality_before;
|
||||
bool drawCastNameTag_atCastOrigin_before;
|
||||
bool drawCastNameTag_atHitPositions_before;
|
||||
int maxListedColliders_inOverlapVolumesTextList_before;
|
||||
int maxOverlapingCollidersWithUntruncatedText_before;
|
||||
float forcedConstantScreenspaceTextSize_relToScreenHeight_forOverlapResultTexts_before;
|
||||
float forcedConstantWorldspaceTextSize_forOverlapResultTexts_before;
|
||||
DrawBasics.CameraForAutomaticOrientation cameraForAutomaticOrientation_before;
|
||||
float custom_zPos_forCastVisualisation_before;
|
||||
Vector2 directionOfHitResultText_before;
|
||||
|
||||
public override void InitializeValues_onceInComponentLifetime()
|
||||
{
|
||||
if (text_exclGlobalMarkupTags == null || text_exclGlobalMarkupTags == "")
|
||||
{
|
||||
text_exclGlobalMarkupTags = "Collisions2D from " + this.gameObject.name;
|
||||
text_inclGlobalMarkupTags = "Collisions2D from " + this.gameObject.name;
|
||||
}
|
||||
|
||||
customVector3Configs[0].picker_isOutfolded = true;
|
||||
customVector3Configs[0].source = CustomVector3Source.manualInput;
|
||||
customVector3Configs[0].clipboardForManualInput = Vector3.one;
|
||||
customVector3Configs[0].vectorInterpretation = VectorInterpretation.globalSpace;
|
||||
|
||||
customVector2Configs[0].picker_isOutfolded = true;
|
||||
customVector2Configs[0].source = CustomVector2Source.rotationAroundZStartingFromRight;
|
||||
customVector2Configs[0].clipboardForManualInput = Vector2.one;
|
||||
customVector2Configs[0].vectorInterpretation = VectorInterpretation.globalSpace;
|
||||
}
|
||||
|
||||
public override void InitializeValues_alsoOnPlaymodeEnter_andOnComponentCreatedAsCopy()
|
||||
{
|
||||
if (shape == Shape.collidersOnThisGameobject)
|
||||
{
|
||||
if (CheckIfGameobjectHasASupportedCollider() == false)
|
||||
{
|
||||
shape = Shape.box;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawVisualizedObject()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
TryFetchCurrentEnabledStateOfColliders2DOnThisGameobjectsHierarchy();
|
||||
Save_globalDrawPhysics2DOptions_beforeThisDrawOperation();
|
||||
try
|
||||
{
|
||||
Set_globalDrawPhysics2DOptions_toValuesFromInpsector();
|
||||
TryDisableEnabledStateOfColliders2DOnThisGameobjectsHierarchy();
|
||||
CastRespCheckTheColliders2D_andDrawThem();
|
||||
}
|
||||
catch { }
|
||||
TryRestoreEnabledStateOfColliders2DOnThisGameobjectsHierarchy();
|
||||
Restore_globalDrawPhysics2DOptions_toValuesFromBefore();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CheckIfGameobjectHasASupportedCollider()
|
||||
{
|
||||
if ((this.gameObject.GetComponent<BoxCollider2D>() == null) && (this.gameObject.GetComponent<CircleCollider2D>() == null) && (this.gameObject.GetComponent<CapsuleCollider2D>() == null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void TryFetchCurrentEnabledStateOfColliders2DOnThisGameobjectsHierarchy()
|
||||
{
|
||||
if (excludeCollidersOnThisGO || excludeCollidersOnParentGOs || excludeCollidersOnChildrenGOs) //The other flag's threads need "allCollidersOnThisGameobject"
|
||||
{
|
||||
allColliders2DOnThisGameobject = this.gameObject.GetComponents<Collider2D>();
|
||||
if (allColliders2DOnThisGameobject != null)
|
||||
{
|
||||
for (int i = 0; i < allColliders2DOnThisGameobject.Length; i++)
|
||||
{
|
||||
if (allColliders2DOnThisGameobject[i] != null)
|
||||
{
|
||||
UtilitiesDXXL_List.AddToABoolList(ref enabledState_ofAllColliders2DOnThisGO_beforeCurrentDrawOperation, allColliders2DOnThisGameobject[i].enabled, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (excludeCollidersOnParentGOs)
|
||||
{
|
||||
allColliders2DOnThisGameobjectAndOnParents = this.gameObject.GetComponentsInParent<Collider2D>();
|
||||
if (allColliders2DOnThisGameobjectAndOnParents != null)
|
||||
{
|
||||
for (int i = 0; i < allColliders2DOnThisGameobjectAndOnParents.Length; i++)
|
||||
{
|
||||
if (allColliders2DOnThisGameobjectAndOnParents[i] != null)
|
||||
{
|
||||
UtilitiesDXXL_List.AddToABoolList(ref enabledState_ofAllColliders2DOnThisGOPlusParents_beforeCurrentDrawOperation, allColliders2DOnThisGameobjectAndOnParents[i].enabled, i);
|
||||
UtilitiesDXXL_List.AddToABoolList(ref isOnThisGO_forAllColliders2DOnThisGOPlusParents_beforeCurrentDrawOperation, CheckIfCollider2DIsOnThisGameobject(allColliders2DOnThisGameobjectAndOnParents[i]), i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (excludeCollidersOnChildrenGOs)
|
||||
{
|
||||
allColliders2DOnThisGameobjectAndOnChildren = this.gameObject.GetComponentsInChildren<Collider2D>();
|
||||
|
||||
if (allColliders2DOnThisGameobjectAndOnChildren != null)
|
||||
{
|
||||
for (int i = 0; i < allColliders2DOnThisGameobjectAndOnChildren.Length; i++)
|
||||
{
|
||||
if (allColliders2DOnThisGameobjectAndOnChildren[i] != null)
|
||||
{
|
||||
UtilitiesDXXL_List.AddToABoolList(ref enabledState_ofAllColliders2DOnThisGOPlusChildren_beforeCurrentDrawOperation, allColliders2DOnThisGameobjectAndOnChildren[i].enabled, i);
|
||||
UtilitiesDXXL_List.AddToABoolList(ref isOnThisGO_forAllColliders2DOnThisGOPlusChildren_beforeCurrentDrawOperation, CheckIfCollider2DIsOnThisGameobject(allColliders2DOnThisGameobjectAndOnChildren[i]), i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CheckIfCollider2DIsOnThisGameobject(Collider2D collider2D_toCheckIfItIsOnThisGameobject)
|
||||
{
|
||||
if (collider2D_toCheckIfItIsOnThisGameobject != null)
|
||||
{
|
||||
if (allColliders2DOnThisGameobject != null)
|
||||
{
|
||||
for (int i = 0; i < allColliders2DOnThisGameobject.Length; i++)
|
||||
{
|
||||
if (allColliders2DOnThisGameobject[i] != null)
|
||||
{
|
||||
if (allColliders2DOnThisGameobject[i] == collider2D_toCheckIfItIsOnThisGameobject)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GetEnabledStateBeforeCurrentDrawOperation_ofCollider2DComponentOnThisGameobject(Collider2D collider2DD_toRetrieveEnabledStateFor)
|
||||
{
|
||||
if (collider2DD_toRetrieveEnabledStateFor != null)
|
||||
{
|
||||
if (allColliders2DOnThisGameobject != null)
|
||||
{
|
||||
for (int i = 0; i < allColliders2DOnThisGameobject.Length; i++)
|
||||
{
|
||||
if (allColliders2DOnThisGameobject[i] != null)
|
||||
{
|
||||
if (allColliders2DOnThisGameobject[i] == collider2DD_toRetrieveEnabledStateFor)
|
||||
{
|
||||
return enabledState_ofAllColliders2DOnThisGO_beforeCurrentDrawOperation[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void TryDisableEnabledStateOfColliders2DOnThisGameobjectsHierarchy()
|
||||
{
|
||||
if (excludeCollidersOnThisGO)
|
||||
{
|
||||
if (allColliders2DOnThisGameobject != null)
|
||||
{
|
||||
for (int i = 0; i < allColliders2DOnThisGameobject.Length; i++)
|
||||
{
|
||||
if (allColliders2DOnThisGameobject[i] != null)
|
||||
{
|
||||
allColliders2DOnThisGameobject[i].enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (excludeCollidersOnParentGOs)
|
||||
{
|
||||
if (allColliders2DOnThisGameobjectAndOnParents != null)
|
||||
{
|
||||
for (int i = 0; i < allColliders2DOnThisGameobjectAndOnParents.Length; i++)
|
||||
{
|
||||
if (allColliders2DOnThisGameobjectAndOnParents[i] != null)
|
||||
{
|
||||
if (isOnThisGO_forAllColliders2DOnThisGOPlusParents_beforeCurrentDrawOperation[i] == false)
|
||||
{
|
||||
allColliders2DOnThisGameobjectAndOnParents[i].enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (excludeCollidersOnChildrenGOs)
|
||||
{
|
||||
if (allColliders2DOnThisGameobjectAndOnChildren != null)
|
||||
{
|
||||
for (int i = 0; i < allColliders2DOnThisGameobjectAndOnChildren.Length; i++)
|
||||
{
|
||||
if (allColliders2DOnThisGameobjectAndOnChildren[i] != null)
|
||||
{
|
||||
if (isOnThisGO_forAllColliders2DOnThisGOPlusChildren_beforeCurrentDrawOperation[i] == false)
|
||||
{
|
||||
allColliders2DOnThisGameobjectAndOnChildren[i].enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TryRestoreEnabledStateOfColliders2DOnThisGameobjectsHierarchy()
|
||||
{
|
||||
if (excludeCollidersOnThisGO)
|
||||
{
|
||||
if (allColliders2DOnThisGameobject != null)
|
||||
{
|
||||
for (int i = 0; i < allColliders2DOnThisGameobject.Length; i++)
|
||||
{
|
||||
if (allColliders2DOnThisGameobject[i] != null)
|
||||
{
|
||||
allColliders2DOnThisGameobject[i].enabled = enabledState_ofAllColliders2DOnThisGO_beforeCurrentDrawOperation[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (excludeCollidersOnParentGOs)
|
||||
{
|
||||
if (allColliders2DOnThisGameobjectAndOnParents != null)
|
||||
{
|
||||
for (int i = 0; i < allColliders2DOnThisGameobjectAndOnParents.Length; i++)
|
||||
{
|
||||
if (allColliders2DOnThisGameobjectAndOnParents[i] != null)
|
||||
{
|
||||
if (isOnThisGO_forAllColliders2DOnThisGOPlusParents_beforeCurrentDrawOperation[i] == false)
|
||||
{
|
||||
allColliders2DOnThisGameobjectAndOnParents[i].enabled = enabledState_ofAllColliders2DOnThisGOPlusParents_beforeCurrentDrawOperation[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (excludeCollidersOnChildrenGOs)
|
||||
{
|
||||
if (allColliders2DOnThisGameobjectAndOnChildren != null)
|
||||
{
|
||||
for (int i = 0; i < allColliders2DOnThisGameobjectAndOnChildren.Length; i++)
|
||||
{
|
||||
if (allColliders2DOnThisGameobjectAndOnChildren[i] != null)
|
||||
{
|
||||
if (isOnThisGO_forAllColliders2DOnThisGOPlusChildren_beforeCurrentDrawOperation[i] == false)
|
||||
{
|
||||
allColliders2DOnThisGameobjectAndOnChildren[i].enabled = enabledState_ofAllColliders2DOnThisGOPlusChildren_beforeCurrentDrawOperation[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Save_globalDrawPhysics2DOptions_beforeThisDrawOperation()
|
||||
{
|
||||
colorForNonHittingCasts_before = DrawPhysics2D.colorForNonHittingCasts;
|
||||
colorForHittingCasts_before = DrawPhysics2D.colorForHittingCasts;
|
||||
colorForCastLineBeyondHit_before = DrawPhysics2D.colorForCastLineBeyondHit;
|
||||
colorForCastsHitText_before = DrawPhysics2D.colorForCastsHitText;
|
||||
scaleFactor_forCastHitTextSize_before = DrawPhysics2D.scaleFactor_forCastHitTextSize;
|
||||
castCorridorVisualizerDensity_before = DrawPhysics2D.castCorridorVisualizerDensity;
|
||||
visualizationQuality_before = DrawPhysics2D.visualizationQuality;
|
||||
drawCastNameTag_atCastOrigin_before = DrawPhysics2D.drawCastNameTag_atCastOrigin;
|
||||
drawCastNameTag_atHitPositions_before = DrawPhysics2D.drawCastNameTag_atHitPositions;
|
||||
custom_zPos_forCastVisualisation_before = DrawPhysics2D.custom_zPos_forCastVisualisation;
|
||||
maxListedColliders_inOverlapVolumesTextList_before = DrawPhysics2D.MaxListedColliders_inOverlapVolumesTextList;
|
||||
maxOverlapingCollidersWithUntruncatedText_before = DrawPhysics2D.maxOverlapingCollidersWithUntruncatedText;
|
||||
forcedConstantScreenspaceTextSize_relToScreenHeight_forOverlapResultTexts_before = DrawPhysics2D.forcedConstantScreenspaceTextSize_relToScreenHeight_forOverlapResultTexts;
|
||||
forcedConstantWorldspaceTextSize_forOverlapResultTexts_before = DrawPhysics2D.forcedConstantWorldspaceTextSize_forOverlapResultTexts;
|
||||
cameraForAutomaticOrientation_before = DrawBasics.cameraForAutomaticOrientation;
|
||||
|
||||
if (doOverwriteColorForCastsHitNormals)
|
||||
{
|
||||
overwriteColorForCastsHitNormals_before = DrawPhysics2D.overwriteColorForCastsHitNormals;
|
||||
}
|
||||
|
||||
if (useCustomDirectionForHitResultText)
|
||||
{
|
||||
directionOfHitResultText_before = DrawPhysics2D.directionOfHitResultText;
|
||||
}
|
||||
}
|
||||
|
||||
void Set_globalDrawPhysics2DOptions_toValuesFromInpsector()
|
||||
{
|
||||
DrawPhysics2D.colorForNonHittingCasts = colorForNonHittingCasts;
|
||||
DrawPhysics2D.colorForHittingCasts = colorForHittingCasts;
|
||||
DrawPhysics2D.colorForCastLineBeyondHit = colorForCastLineBeyondHit;
|
||||
DrawPhysics2D.colorForCastsHitText = colorForCastsHitText;
|
||||
DrawPhysics2D.scaleFactor_forCastHitTextSize = scaleFactor_forCastHitTextSize;
|
||||
DrawPhysics2D.castCorridorVisualizerDensity = castCorridorVisualizerDensity;
|
||||
DrawPhysics2D.visualizationQuality = PhysicsVisualizer.Map_saveDrawnLinesType_to_visualizationQuality(saveDrawnLinesType);
|
||||
DrawPhysics2D.drawCastNameTag_atCastOrigin = drawCastNameTag_atCastOrigin;
|
||||
DrawPhysics2D.drawCastNameTag_atHitPositions = drawCastNameTag_atHitPositions;
|
||||
DrawPhysics2D.custom_zPos_forCastVisualisation = GetZPos_global_for2D();
|
||||
DrawPhysics2D.MaxListedColliders_inOverlapVolumesTextList = maxListedColliders_inOverlapVolumesTextList;
|
||||
DrawPhysics2D.maxOverlapingCollidersWithUntruncatedText = maxOverlapingCollidersWithUntruncatedText;
|
||||
|
||||
switch (overlapResultTextSizeInterpretation)
|
||||
{
|
||||
case PhysicsVisualizer.OverlapResultTextSizeInterpretation.relativeToTheSizeOfTheOverlapingPhysicsShape:
|
||||
DrawPhysics2D.forcedConstantScreenspaceTextSize_relToScreenHeight_forOverlapResultTexts = 0.0f;
|
||||
DrawPhysics2D.forcedConstantWorldspaceTextSize_forOverlapResultTexts = 0.0f;
|
||||
break;
|
||||
case PhysicsVisualizer.OverlapResultTextSizeInterpretation.fixedWorldSpaceSize:
|
||||
DrawPhysics2D.forcedConstantScreenspaceTextSize_relToScreenHeight_forOverlapResultTexts = 0.0f;
|
||||
DrawPhysics2D.forcedConstantWorldspaceTextSize_forOverlapResultTexts = forcedConstantWorldspaceTextSize_forOverlapResultTexts;
|
||||
break;
|
||||
case PhysicsVisualizer.OverlapResultTextSizeInterpretation.relativeToTheSceneViewWindowSize:
|
||||
DrawPhysics2D.forcedConstantScreenspaceTextSize_relToScreenHeight_forOverlapResultTexts = forcedConstantScreenspaceTextSize_relToScreenHeight_forOverlapResultTexts;
|
||||
DrawPhysics2D.forcedConstantWorldspaceTextSize_forOverlapResultTexts = 0.0f;
|
||||
DrawBasics.cameraForAutomaticOrientation = DrawBasics.CameraForAutomaticOrientation.sceneViewCamera;
|
||||
break;
|
||||
case PhysicsVisualizer.OverlapResultTextSizeInterpretation.relativeToTheGameViewWindowSize:
|
||||
DrawPhysics2D.forcedConstantScreenspaceTextSize_relToScreenHeight_forOverlapResultTexts = forcedConstantScreenspaceTextSize_relToScreenHeight_forOverlapResultTexts;
|
||||
DrawPhysics2D.forcedConstantWorldspaceTextSize_forOverlapResultTexts = 0.0f;
|
||||
DrawBasics.cameraForAutomaticOrientation = DrawBasics.CameraForAutomaticOrientation.gameViewCamera;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (doOverwriteColorForCastsHitNormals)
|
||||
{
|
||||
DrawPhysics2D.overwriteColorForCastsHitNormals = overwriteColorForCastsHitNormals;
|
||||
}
|
||||
|
||||
if (useCustomDirectionForHitResultText)
|
||||
{
|
||||
DrawPhysics2D.directionOfHitResultText = customDirectionForHitResultText;
|
||||
}
|
||||
}
|
||||
|
||||
void Restore_globalDrawPhysics2DOptions_toValuesFromBefore()
|
||||
{
|
||||
DrawPhysics2D.colorForNonHittingCasts = colorForNonHittingCasts_before;
|
||||
DrawPhysics2D.colorForHittingCasts = colorForHittingCasts_before;
|
||||
DrawPhysics2D.colorForCastLineBeyondHit = colorForCastLineBeyondHit_before;
|
||||
DrawPhysics2D.colorForCastsHitText = colorForCastsHitText_before;
|
||||
DrawPhysics2D.scaleFactor_forCastHitTextSize = scaleFactor_forCastHitTextSize_before;
|
||||
DrawPhysics2D.castCorridorVisualizerDensity = castCorridorVisualizerDensity_before;
|
||||
DrawPhysics2D.visualizationQuality = visualizationQuality_before;
|
||||
DrawPhysics2D.drawCastNameTag_atCastOrigin = drawCastNameTag_atCastOrigin_before;
|
||||
DrawPhysics2D.drawCastNameTag_atHitPositions = drawCastNameTag_atHitPositions_before;
|
||||
DrawPhysics2D.custom_zPos_forCastVisualisation = custom_zPos_forCastVisualisation_before;
|
||||
DrawPhysics2D.MaxListedColliders_inOverlapVolumesTextList = maxListedColliders_inOverlapVolumesTextList_before;
|
||||
DrawPhysics2D.maxOverlapingCollidersWithUntruncatedText = maxOverlapingCollidersWithUntruncatedText_before;
|
||||
DrawPhysics2D.forcedConstantScreenspaceTextSize_relToScreenHeight_forOverlapResultTexts = forcedConstantScreenspaceTextSize_relToScreenHeight_forOverlapResultTexts_before;
|
||||
DrawPhysics2D.forcedConstantWorldspaceTextSize_forOverlapResultTexts = forcedConstantWorldspaceTextSize_forOverlapResultTexts_before;
|
||||
DrawPhysics2D.forcedConstantWorldspaceTextSize_forOverlapResultTexts = forcedConstantWorldspaceTextSize_forOverlapResultTexts_before;
|
||||
DrawBasics.cameraForAutomaticOrientation = cameraForAutomaticOrientation_before;
|
||||
|
||||
if (doOverwriteColorForCastsHitNormals)
|
||||
{
|
||||
DrawPhysics2D.overwriteColorForCastsHitNormals = overwriteColorForCastsHitNormals_before;
|
||||
}
|
||||
|
||||
if (useCustomDirectionForHitResultText)
|
||||
{
|
||||
DrawPhysics2D.directionOfHitResultText = directionOfHitResultText_before;
|
||||
}
|
||||
}
|
||||
|
||||
void CastRespCheckTheColliders2D_andDrawThem()
|
||||
{
|
||||
used_distance = Get_used_distance();
|
||||
switch (shape)
|
||||
{
|
||||
case Shape.collidersOnThisGameobject:
|
||||
theGameobjectHasACompatibleAndEnabledCollider = false;
|
||||
aVisualizedBoxCollider2DOnThisComponent_hasANonZeroEdge = false;
|
||||
aVisualizedBoxCollider2DOnThisComponent_hasAutoTiling = false;
|
||||
CastRespOverlap_boxColliders2DOnThisGameobject();
|
||||
CastRespOverlap_circleColliders2DOnThisGameobject();
|
||||
CastRespOverlap_capsuleColliders2DOnThisGameobject();
|
||||
break;
|
||||
case Shape.box:
|
||||
switch (collisionType)
|
||||
{
|
||||
case CollisionType.cast:
|
||||
BoxCast2D(GetDrawPos2D_global(), Get_sizeOfFinalBoxShape(sizeScaleFactors_ofCastRespCheckedBox), GetUsedRotation());
|
||||
break;
|
||||
case CollisionType.overlap:
|
||||
Box2D_checkRespOverlap(GetDrawPos2D_global(), Get_sizeOfFinalBoxShape(sizeScaleFactors_ofCastRespCheckedBox), GetUsedRotation());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Shape.circle:
|
||||
switch (collisionType)
|
||||
{
|
||||
case CollisionType.cast:
|
||||
CircleCast2D(GetDrawPos2D_global(), GetRadiusOfFinalCircleShape(radiusScaleFactor_ofCastRespCheckedCircle));
|
||||
break;
|
||||
case CollisionType.overlap:
|
||||
Circle2D_checkRespOverlap(GetDrawPos2D_global(), GetRadiusOfFinalCircleShape(radiusScaleFactor_ofCastRespCheckedCircle));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Shape.capsule:
|
||||
switch (collisionType)
|
||||
{
|
||||
case CollisionType.cast:
|
||||
CapsuleCast2D(GetDrawPos2D_global(), Get_sizeOfFinalBoxShape(sizeScaleFactors_ofCastRespCheckedCapsule), capsuleDirection2D_ofManuallyConstructedCapsuleMeaningNotFromCollider, GetUsedRotation());
|
||||
break;
|
||||
case CollisionType.overlap:
|
||||
Capsule2D_checkRespOverlap(GetDrawPos2D_global(), Get_sizeOfFinalBoxShape(sizeScaleFactors_ofCastRespCheckedCapsule), capsuleDirection2D_ofManuallyConstructedCapsuleMeaningNotFromCollider, GetUsedRotation());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Shape.rayOrPoint:
|
||||
switch (collisionType)
|
||||
{
|
||||
case CollisionType.cast:
|
||||
RayCast2D();
|
||||
break;
|
||||
case CollisionType.overlap:
|
||||
Point2D_checkRespOverlap();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Shape.ray3D:
|
||||
Ray3DCastIn2D();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
float Get_used_distance()
|
||||
{
|
||||
if (distanceIsInfinityRespToOtherGO)
|
||||
{
|
||||
if (shape == Shape.ray3D)
|
||||
{
|
||||
if (customVector3Configs[0].source == VisualizerParent.CustomVector3Source.toOtherGameobject)
|
||||
{
|
||||
if (customVector3Configs[0].targetGameObject != null)
|
||||
{
|
||||
return (transform.position - customVector3Configs[0].targetGameObject.transform.position).magnitude;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Mathf.Infinity;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return Mathf.Infinity;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (customVector2Configs[0].source == VisualizerParent.CustomVector2Source.toOtherGameobject)
|
||||
{
|
||||
if (customVector2Configs[0].targetGameObject != null)
|
||||
{
|
||||
Vector2 thisTransformPos_asV2 = new Vector2(transform.position.x, transform.position.y);
|
||||
Vector2 otherGameobjectPos_asV2 = new Vector2(customVector2Configs[0].targetGameObject.transform.position.x, customVector2Configs[0].targetGameObject.transform.position.y);
|
||||
return (thisTransformPos_asV2 - otherGameobjectPos_asV2).magnitude;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Mathf.Infinity;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return Mathf.Infinity;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return adjustedDistance;
|
||||
}
|
||||
}
|
||||
|
||||
float GetUsedRotation()
|
||||
{
|
||||
switch (shapeRotationType)
|
||||
{
|
||||
case ShapeRotationType.transformsRotationPlusOptionalAdditionalRotation:
|
||||
return (transform.rotation.eulerAngles.z + rotationAngleOfShape_additionallyToTransformsAngle);
|
||||
case ShapeRotationType.customRotationIndependentFromTransform:
|
||||
return rotationAngleOfShape_additionallyToTransformsAngle;
|
||||
default:
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void CastRespOverlap_boxColliders2DOnThisGameobject()
|
||||
{
|
||||
boxColliders2D_onThisGameobject = this.gameObject.GetComponents<BoxCollider2D>();
|
||||
if (boxColliders2D_onThisGameobject != null)
|
||||
{
|
||||
for (int i = 0; i < boxColliders2D_onThisGameobject.Length; i++)
|
||||
{
|
||||
if (boxColliders2D_onThisGameobject[i] != null)
|
||||
{
|
||||
if (boxColliders2D_onThisGameobject[i].enabled || GetEnabledStateBeforeCurrentDrawOperation_ofCollider2DComponentOnThisGameobject(boxColliders2D_onThisGameobject[i]))
|
||||
{
|
||||
theGameobjectHasACompatibleAndEnabledCollider = true; //this is intentionally outside the "autoTiling"-check
|
||||
if (UtilitiesDXXL_Math.ApproximatelyZero(boxColliders2D_onThisGameobject[i].edgeRadius) == false) { aVisualizedBoxCollider2DOnThisComponent_hasANonZeroEdge = true; }
|
||||
|
||||
if (boxColliders2D_onThisGameobject[i].autoTiling == true)
|
||||
{
|
||||
aVisualizedBoxCollider2DOnThisComponent_hasAutoTiling = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector2 center = GetCenterPosGlobalOfCollider(boxColliders2D_onThisGameobject[i].offset);
|
||||
Vector2 size = Get_sizeOfFinalBoxShape(boxColliders2D_onThisGameobject[i].size);
|
||||
float angle = transform.rotation.eulerAngles.z;
|
||||
switch (collisionType)
|
||||
{
|
||||
case CollisionType.cast:
|
||||
BoxCast2D(center, size, angle);
|
||||
break;
|
||||
case CollisionType.overlap:
|
||||
Box2D_checkRespOverlap(center, size, angle);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CastRespOverlap_circleColliders2DOnThisGameobject()
|
||||
{
|
||||
circleColliders2D_onThisGameobject = this.gameObject.GetComponents<CircleCollider2D>();
|
||||
if (circleColliders2D_onThisGameobject != null)
|
||||
{
|
||||
for (int i = 0; i < circleColliders2D_onThisGameobject.Length; i++)
|
||||
{
|
||||
if (circleColliders2D_onThisGameobject[i] != null)
|
||||
{
|
||||
if (circleColliders2D_onThisGameobject[i].enabled || GetEnabledStateBeforeCurrentDrawOperation_ofCollider2DComponentOnThisGameobject(circleColliders2D_onThisGameobject[i]))
|
||||
{
|
||||
theGameobjectHasACompatibleAndEnabledCollider = true;
|
||||
Vector2 origin = GetCenterPosGlobalOfCollider(circleColliders2D_onThisGameobject[i].offset);
|
||||
float radius = GetRadiusOfFinalCircleShape(circleColliders2D_onThisGameobject[i].radius);
|
||||
switch (collisionType)
|
||||
{
|
||||
case CollisionType.cast:
|
||||
CircleCast2D(origin, radius);
|
||||
break;
|
||||
case CollisionType.overlap:
|
||||
Circle2D_checkRespOverlap(origin, radius);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CastRespOverlap_capsuleColliders2DOnThisGameobject()
|
||||
{
|
||||
capsuleColliders2D_onThisGameobject = this.gameObject.GetComponents<CapsuleCollider2D>();
|
||||
if (capsuleColliders2D_onThisGameobject != null)
|
||||
{
|
||||
for (int i = 0; i < capsuleColliders2D_onThisGameobject.Length; i++)
|
||||
{
|
||||
if (capsuleColliders2D_onThisGameobject[i] != null)
|
||||
{
|
||||
if (capsuleColliders2D_onThisGameobject[i].enabled || GetEnabledStateBeforeCurrentDrawOperation_ofCollider2DComponentOnThisGameobject(capsuleColliders2D_onThisGameobject[i]))
|
||||
{
|
||||
theGameobjectHasACompatibleAndEnabledCollider = true;
|
||||
Vector2 colliderCenter_global = GetCenterPosGlobalOfCollider(capsuleColliders2D_onThisGameobject[i].offset);
|
||||
Vector2 size = Get_sizeOfFinalBoxShape(capsuleColliders2D_onThisGameobject[i].size);
|
||||
float angle = transform.rotation.eulerAngles.z;
|
||||
switch (collisionType)
|
||||
{
|
||||
case CollisionType.cast:
|
||||
CapsuleCast2D(colliderCenter_global, size, capsuleColliders2D_onThisGameobject[i].direction, angle);
|
||||
break;
|
||||
case CollisionType.overlap:
|
||||
Capsule2D_checkRespOverlap(colliderCenter_global, size, capsuleColliders2D_onThisGameobject[i].direction, angle);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float GetRadiusOfFinalCircleShape(float radiusScaleFactor_fromComponentProperty)
|
||||
{
|
||||
return (radiusScaleFactor_fromComponentProperty * UtilitiesDXXL_Math.GetBiggestAbsComponent_butReassignTheSign(transform.lossyScale, UtilitiesDXXL_Math.Dimension.z));
|
||||
}
|
||||
|
||||
Vector2 Get_sizeOfFinalBoxShape(Vector2 sizeScaleFactors_fromComponentProperty)
|
||||
{
|
||||
Vector2 transformsLossyScale_asV2 = new Vector2(transform.lossyScale.x, transform.lossyScale.y);
|
||||
return Vector2.Scale(transformsLossyScale_asV2, sizeScaleFactors_fromComponentProperty);
|
||||
}
|
||||
|
||||
Vector2 GetCenterPosGlobalOfCollider(Vector2 collidersLocalCenter)
|
||||
{
|
||||
Vector3 xOffset = transform.right * transform.lossyScale.x * collidersLocalCenter.x;
|
||||
Vector3 yOffset = transform.up * transform.lossyScale.y * collidersLocalCenter.y;
|
||||
return (transform.position + xOffset + yOffset);
|
||||
}
|
||||
|
||||
void BoxCast2D(Vector2 origin, Vector2 size, float angle)
|
||||
{
|
||||
if (wantedHits == WantedHits.all)
|
||||
{
|
||||
numberOfFoundHits = DrawPhysics2D.BoxCast(origin, size, angle, Get_customVector2_1_inGlobalSpaceUnits(), GetContactFilter2D_fromInspectorSpecifiedOptions(), unusedRaycastHitResults, used_distance, text_inclGlobalMarkupTags, 0.0f, hiddenByNearerObjects);
|
||||
}
|
||||
else
|
||||
{
|
||||
Get_minAndMaxDepth(out float used_minDepth, out float used_maxDepth);
|
||||
RaycastHit2D result = DrawPhysics2D.BoxCast(origin, size, angle, Get_customVector2_1_inGlobalSpaceUnits(), used_distance, layerMask, used_minDepth, used_maxDepth, text_inclGlobalMarkupTags, 0.0f, hiddenByNearerObjects);
|
||||
numberOfFoundHits = (result.collider != null) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
void CircleCast2D(Vector2 origin, float radius)
|
||||
{
|
||||
if (wantedHits == WantedHits.all)
|
||||
{
|
||||
numberOfFoundHits = DrawPhysics2D.CircleCast(origin, radius, Get_customVector2_1_inGlobalSpaceUnits(), GetContactFilter2D_fromInspectorSpecifiedOptions(), unusedRaycastHitResults, used_distance, text_inclGlobalMarkupTags, 0.0f, hiddenByNearerObjects);
|
||||
}
|
||||
else
|
||||
{
|
||||
Get_minAndMaxDepth(out float used_minDepth, out float used_maxDepth);
|
||||
RaycastHit2D result = DrawPhysics2D.CircleCast(origin, radius, Get_customVector2_1_inGlobalSpaceUnits(), used_distance, layerMask, used_minDepth, used_maxDepth, text_inclGlobalMarkupTags, 0.0f, hiddenByNearerObjects);
|
||||
numberOfFoundHits = (result.collider != null) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
void CapsuleCast2D(Vector2 origin, Vector2 size, CapsuleDirection2D capsuleDirection, float angle)
|
||||
{
|
||||
if (wantedHits == WantedHits.all)
|
||||
{
|
||||
numberOfFoundHits = DrawPhysics2D.CapsuleCast(origin, size, capsuleDirection, angle, Get_customVector2_1_inGlobalSpaceUnits(), GetContactFilter2D_fromInspectorSpecifiedOptions(), unusedRaycastHitResults, used_distance, text_inclGlobalMarkupTags, 0.0f, hiddenByNearerObjects);
|
||||
}
|
||||
else
|
||||
{
|
||||
Get_minAndMaxDepth(out float used_minDepth, out float used_maxDepth);
|
||||
RaycastHit2D result = DrawPhysics2D.CapsuleCast(origin, size, capsuleDirection, angle, Get_customVector2_1_inGlobalSpaceUnits(), used_distance, layerMask, used_minDepth, used_maxDepth, text_inclGlobalMarkupTags, 0.0f, hiddenByNearerObjects);
|
||||
numberOfFoundHits = (result.collider != null) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
void RayCast2D()
|
||||
{
|
||||
if (wantedHits == WantedHits.all)
|
||||
{
|
||||
numberOfFoundHits = DrawPhysics2D.Raycast(GetDrawPos2D_global(), Get_customVector2_1_inGlobalSpaceUnits(), GetContactFilter2D_fromInspectorSpecifiedOptions(), unusedRaycastHitResults, used_distance, text_inclGlobalMarkupTags, 0.0f, hiddenByNearerObjects);
|
||||
}
|
||||
else
|
||||
{
|
||||
Get_minAndMaxDepth(out float used_minDepth, out float used_maxDepth);
|
||||
RaycastHit2D result = DrawPhysics2D.Raycast(GetDrawPos2D_global(), Get_customVector2_1_inGlobalSpaceUnits(), used_distance, layerMask, used_minDepth, used_maxDepth, text_inclGlobalMarkupTags, 0.0f, hiddenByNearerObjects);
|
||||
numberOfFoundHits = (result.collider != null) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Ray3DCastIn2D()
|
||||
{
|
||||
Ray ray = new Ray(GetDrawPos3D_global(), Get_customVector3_1_inGlobalSpaceUnits());
|
||||
if (wantedHits == WantedHits.all)
|
||||
{
|
||||
RaycastHit2D[] results = DrawPhysics2D.GetRayIntersectionAll(ray, used_distance, layerMask, text_inclGlobalMarkupTags, 0.0f, hiddenByNearerObjects);
|
||||
numberOfFoundHits = (results != null) ? results.Length : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
RaycastHit2D result = DrawPhysics2D.GetRayIntersection(ray, used_distance, layerMask, text_inclGlobalMarkupTags, 0.0f, hiddenByNearerObjects);
|
||||
numberOfFoundHits = (result.collider != null) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Box2D_checkRespOverlap(Vector2 point, Vector2 size, float angle)
|
||||
{
|
||||
if (wantedHits == WantedHits.all)
|
||||
{
|
||||
numberOfFoundHits = DrawPhysics2D.OverlapBox(point, size, angle, GetContactFilter2D_fromInspectorSpecifiedOptions(), unusedResultColliders, text_inclGlobalMarkupTags, 0.0f, hiddenByNearerObjects);
|
||||
}
|
||||
else
|
||||
{
|
||||
Get_minAndMaxDepth(out float used_minDepth, out float used_maxDepth);
|
||||
Collider2D overlappingCollider = DrawPhysics2D.OverlapBox(point, size, angle, layerMask, used_minDepth, used_maxDepth, text_inclGlobalMarkupTags, 0.0f, hiddenByNearerObjects);
|
||||
numberOfFoundHits = (overlappingCollider != null) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Circle2D_checkRespOverlap(Vector2 point, float radius)
|
||||
{
|
||||
if (wantedHits == WantedHits.all)
|
||||
{
|
||||
numberOfFoundHits = DrawPhysics2D.OverlapCircle(point, radius, GetContactFilter2D_fromInspectorSpecifiedOptions(), unusedResultColliders, text_inclGlobalMarkupTags, 0.0f, hiddenByNearerObjects);
|
||||
}
|
||||
else
|
||||
{
|
||||
Get_minAndMaxDepth(out float used_minDepth, out float used_maxDepth);
|
||||
Collider2D overlappingCollider = DrawPhysics2D.OverlapCircle(point, radius, layerMask, used_minDepth, used_maxDepth, text_inclGlobalMarkupTags, 0.0f, hiddenByNearerObjects);
|
||||
numberOfFoundHits = (overlappingCollider != null) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Capsule2D_checkRespOverlap(Vector2 point, Vector2 size, CapsuleDirection2D direction, float angle)
|
||||
{
|
||||
if (wantedHits == WantedHits.all)
|
||||
{
|
||||
numberOfFoundHits = DrawPhysics2D.OverlapCapsule(point, size, direction, angle, GetContactFilter2D_fromInspectorSpecifiedOptions(), unusedResultColliders, text_inclGlobalMarkupTags, 0.0f, hiddenByNearerObjects);
|
||||
}
|
||||
else
|
||||
{
|
||||
Get_minAndMaxDepth(out float used_minDepth, out float used_maxDepth);
|
||||
Collider2D overlappingCollider = DrawPhysics2D.OverlapCapsule(point, size, direction, angle, layerMask, used_minDepth, used_maxDepth, text_inclGlobalMarkupTags, 0.0f, hiddenByNearerObjects);
|
||||
numberOfFoundHits = (overlappingCollider != null) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Point2D_checkRespOverlap()
|
||||
{
|
||||
if (wantedHits == WantedHits.all)
|
||||
{
|
||||
numberOfFoundHits = DrawPhysics2D.OverlapPoint(GetDrawPos2D_global(), GetContactFilter2D_fromInspectorSpecifiedOptions(), unusedResultColliders, text_inclGlobalMarkupTags, 0.0f, hiddenByNearerObjects);
|
||||
}
|
||||
else
|
||||
{
|
||||
Get_minAndMaxDepth(out float used_minDepth, out float used_maxDepth);
|
||||
Collider2D overlappingCollider = DrawPhysics2D.OverlapPoint(GetDrawPos2D_global(), layerMask, used_minDepth, used_maxDepth, text_inclGlobalMarkupTags, 0.0f, hiddenByNearerObjects);
|
||||
numberOfFoundHits = (overlappingCollider != null) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
ContactFilter2D GetContactFilter2D_fromInspectorSpecifiedOptions()
|
||||
{
|
||||
ContactFilter2D created_contactFilter2D = new ContactFilter2D();
|
||||
|
||||
created_contactFilter2D.useLayerMask = true;
|
||||
created_contactFilter2D.layerMask = layerMask;
|
||||
|
||||
created_contactFilter2D.useDepth = useDepth;
|
||||
created_contactFilter2D.minDepth = minDepth;
|
||||
created_contactFilter2D.maxDepth = maxDepth;
|
||||
created_contactFilter2D.useOutsideDepth = useOutsideDepth;
|
||||
|
||||
created_contactFilter2D.useNormalAngle = useNormalAngle;
|
||||
created_contactFilter2D.minNormalAngle = minNormalAngle;
|
||||
created_contactFilter2D.maxNormalAngle = maxNormalAngle;
|
||||
created_contactFilter2D.useOutsideNormalAngle = useOutsideNormalAngle;
|
||||
|
||||
created_contactFilter2D.useTriggers = useTriggers;
|
||||
|
||||
return created_contactFilter2D;
|
||||
}
|
||||
|
||||
void Get_minAndMaxDepth(out float used_minDepth, out float used_maxDepth)
|
||||
{
|
||||
if (useDepth)
|
||||
{
|
||||
used_minDepth = minDepth;
|
||||
used_maxDepth = maxDepth;
|
||||
}
|
||||
else
|
||||
{
|
||||
used_minDepth = Mathf.NegativeInfinity;
|
||||
used_maxDepth = Mathf.Infinity;
|
||||
}
|
||||
}
|
||||
|
||||
static Vector2 GetInitialValueFor_customDirectionForHitResultText()
|
||||
{
|
||||
if (UtilitiesDXXL_Math.IsDefaultVector(DrawPhysics2D.directionOfHitResultText))
|
||||
{
|
||||
return DrawBasics.Default_textOffsetDirection_forPointTags;
|
||||
}
|
||||
else
|
||||
{
|
||||
return DrawPhysics2D.directionOfHitResultText;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8450f185e9b2ff3498d5f48b567f7655
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,352 @@
|
||||
namespace DrawXXL
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
[HelpURL("https://www.symphonygames.net/drawxxldocumentation/index.html")]
|
||||
[AddComponentMenu("Xeric Library/DebugDrawLibrary/2D/Shape Drawer 2D")]
|
||||
[DefaultExecutionOrder(31000)] //negative numers are early, positive numbers are late. Range is till 32000 to both negative and positive direction.
|
||||
public class ShapeDrawer2D : VisualizerParent
|
||||
{
|
||||
public enum ShapeType { circle, ellipse, star, capsule, icon, triangle, square, pentagon, hexagon, septagon, octagon, decagon, dot }
|
||||
[SerializeField] ShapeType shapeType = ShapeType.circle;
|
||||
public enum ShapeSizeDefinition { relativeToGlobalScaleOfTheTransformUsingTheBiggestAbsoluteComponentButIgnoringZ, absoluteUnits, relativeToTheSceneViewWindowSize, relativeToTheGameViewWindowSize };
|
||||
[SerializeField] ShapeSizeDefinition sizeDefinition = ShapeSizeDefinition.relativeToGlobalScaleOfTheTransformUsingTheBiggestAbsoluteComponentButIgnoringZ;
|
||||
[SerializeField] ShapeDrawer.ShapeAttachedTextsizeReferenceContext shapeAttachedTextsizeReferenceContext = ShapeDrawer.ShapeAttachedTextsizeReferenceContext.sceneViewWindowSize;
|
||||
[SerializeField] float textSize_value = 0.1f;
|
||||
[SerializeField] [Range(0.001f, 0.2f)] float textSize_value_relToScreen = 0.02f;
|
||||
|
||||
float lengthOfScreenDiagonal_atDrawnObjectsPosition = 1.0f;
|
||||
float biggestAbsGlobalSizeComponentOfTransform_ignoringZ = 1.0f;
|
||||
[SerializeField] bool cameraForSizeDefinitionIsAvailable = false;
|
||||
Camera gameviewCameraForDrawing;
|
||||
|
||||
//general settings:
|
||||
[SerializeField] [Range(-360.0f, 360.0f)] float rotation_angleDegCC = 0.0f;
|
||||
[SerializeField] Color color = DrawBasics.defaultColor;
|
||||
[SerializeField] DrawBasics.LineStyle lineStyle = DrawBasics.LineStyle.solid;
|
||||
[SerializeField] DrawBasics.LineStyle fillStyle = DrawBasics.LineStyle.invisible;
|
||||
[SerializeField] float shapeFillDensity = 1.0f;
|
||||
[SerializeField] bool textBlockAboveLine = false;
|
||||
|
||||
//shape specific settings:
|
||||
[SerializeField] DrawBasics.IconType iconType = DrawBasics.IconType.car;
|
||||
[SerializeField] bool iconIsMirroredHorizontally = false;
|
||||
[SerializeField] bool showAtlasOfAllAvailableIcons = false;
|
||||
[SerializeField] ShapeDrawer.CornerOptionsForIrregularStar cornerOptionsForIrregularStar = ShapeDrawer.CornerOptionsForIrregularStar._5;
|
||||
[SerializeField] CapsuleDirection2D capusleDirection2D = CapsuleDirection2D.Vertical;
|
||||
[SerializeField] float dotDensity = 1.0f;
|
||||
|
||||
//general - scale type dependent:
|
||||
[SerializeField] ScreenRelativeValue linesWidth = new ScreenRelativeValue(0.0f, 0.0f, ScreenRelativeValue.ScaleMode.absolute);
|
||||
[SerializeField] ScreenRelativeValue stylePatternScaleFactor = new ScreenRelativeValue(1.0f, 0.1f, ScreenRelativeValue.ScaleMode.absolute);
|
||||
|
||||
//shape specific - scale type dependent:
|
||||
[SerializeField] ScreenRelativeValue radiusScaleFactor = new ScreenRelativeValue(0.5f, 0.05f, ScreenRelativeValue.ScaleMode.absolute);
|
||||
[SerializeField] ScreenRelativeValue sizeOfIconScaleFactor = new ScreenRelativeValue(1.0f, 0.1f, ScreenRelativeValue.ScaleMode.absolute);
|
||||
[SerializeField] ScreenRelativeValue width_scaleFactor_initialValue1 = new ScreenRelativeValue(1.0f, 0.1f, ScreenRelativeValue.ScaleMode.absolute);
|
||||
[SerializeField] ScreenRelativeValue height_scaleFactor_initialValue1 = new ScreenRelativeValue(1.0f, 0.1f, ScreenRelativeValue.ScaleMode.absolute);
|
||||
[SerializeField] ScreenRelativeValue height_scaleFactor_initialValue2 = new ScreenRelativeValue(2.0f, 0.2f, ScreenRelativeValue.ScaleMode.absolute);
|
||||
|
||||
public override void InitializeValues_onceInComponentLifetime()
|
||||
{
|
||||
TrySetTextToEmptyString();
|
||||
}
|
||||
|
||||
public override void DrawVisualizedObject()
|
||||
{
|
||||
CacheSizeScaleFactors();
|
||||
switch (shapeType)
|
||||
{
|
||||
case ShapeType.circle:
|
||||
float size_asFloat = 2.0f * GetRadius();
|
||||
Vector2 size = new Vector2(size_asFloat, size_asFloat);
|
||||
|
||||
Set_globalTextSizeSpecs_reversible();
|
||||
UtilitiesDXXL_Shapes.Set_shapeFillDensity_reversible(shapeFillDensity);
|
||||
DrawBasics2D.Shape(GetDrawPos2D_global(), DrawShapes.Shape2DType.circle, size, color, rotation_angleDegCC, Get_linesWidth(), text_inclGlobalMarkupTags, lineStyle, GetZPos_global_for2D(), Get_stylePatternScaleFactor(), fillStyle, textBlockAboveLine, 0.0f, hiddenByNearerObjects);
|
||||
UtilitiesDXXL_Shapes.Reverse_shapeFillDensity();
|
||||
Reverse_globalTextSizeSpecs();
|
||||
break;
|
||||
case ShapeType.ellipse:
|
||||
Set_globalTextSizeSpecs_reversible();
|
||||
UtilitiesDXXL_Shapes.Set_shapeFillDensity_reversible(shapeFillDensity);
|
||||
DrawBasics2D.Shape(GetDrawPos2D_global(), DrawShapes.Shape2DType.circle, Get_size_initialValueNonUniform(), color, rotation_angleDegCC, Get_linesWidth(), text_inclGlobalMarkupTags, lineStyle, GetZPos_global_for2D(), Get_stylePatternScaleFactor(), fillStyle, textBlockAboveLine, 0.0f, hiddenByNearerObjects);
|
||||
UtilitiesDXXL_Shapes.Reverse_shapeFillDensity();
|
||||
Reverse_globalTextSizeSpecs();
|
||||
break;
|
||||
case ShapeType.star:
|
||||
Set_globalTextSizeSpecs_reversible();
|
||||
DrawBasics2D.Shape(GetDrawPos2D_global(), ShapeDrawer.Get_shape2DType_forIrregularStar(cornerOptionsForIrregularStar), Get_size_initialValueUniform(), color, rotation_angleDegCC, Get_linesWidth(), text_inclGlobalMarkupTags, lineStyle, GetZPos_global_for2D(), Get_stylePatternScaleFactor(), DrawBasics.LineStyle.invisible, textBlockAboveLine, 0.0f, hiddenByNearerObjects);
|
||||
Reverse_globalTextSizeSpecs();
|
||||
break;
|
||||
case ShapeType.capsule:
|
||||
Set_globalTextSizeSpecs_reversible();
|
||||
UtilitiesDXXL_Shapes.Set_shapeFillDensity_reversible(shapeFillDensity);
|
||||
DrawBasics2D.Capsule(GetDrawPos2D_global(), Get_size_initialValueNonUniform(), color, capusleDirection2D, rotation_angleDegCC, Get_linesWidth(), text_inclGlobalMarkupTags, lineStyle, GetZPos_global_for2D(), Get_stylePatternScaleFactor(), fillStyle, false, textBlockAboveLine, 0.0f, hiddenByNearerObjects);
|
||||
UtilitiesDXXL_Shapes.Reverse_shapeFillDensity();
|
||||
Reverse_globalTextSizeSpecs();
|
||||
break;
|
||||
case ShapeType.icon:
|
||||
float sizeOfIcon = GetSizeOfIcon();
|
||||
int strokeWidth_asPPMofSize = 0;
|
||||
if ((UtilitiesDXXL_Math.ApproximatelyZero(sizeOfIcon) == false) && (UtilitiesDXXL_Math.ApproximatelyZero(Get_linesWidth()) == false))
|
||||
{
|
||||
strokeWidth_asPPMofSize = (int)(1000000.0f * (Get_linesWidth() / sizeOfIcon));
|
||||
}
|
||||
DrawBasics2D.Icon(GetDrawPos2D_global(), iconType, color, sizeOfIcon, text_inclGlobalMarkupTags, rotation_angleDegCC, strokeWidth_asPPMofSize, GetZPos_global_for2D(), iconIsMirroredHorizontally, 0.0f, hiddenByNearerObjects);
|
||||
|
||||
if (showAtlasOfAllAvailableIcons)
|
||||
{
|
||||
DrawBasics.DrawAtlasOfAllIconsWithTheirNames(GetDrawPos3D_ofA2DModeTransform_global(), default(Color), default(Color), true, biggestAbsGlobalSizeComponentOfTransform_ignoringZ);
|
||||
}
|
||||
break;
|
||||
case ShapeType.triangle:
|
||||
Set_globalTextSizeSpecs_reversible();
|
||||
UtilitiesDXXL_Shapes.Set_shapeFillDensity_reversible(shapeFillDensity);
|
||||
DrawBasics2D.Shape(GetDrawPos2D_global(), DrawShapes.Shape2DType.triangle, Get_size_initialValueUniform(), color, rotation_angleDegCC, Get_linesWidth(), text_inclGlobalMarkupTags, lineStyle, GetZPos_global_for2D(), Get_stylePatternScaleFactor(), fillStyle, textBlockAboveLine, 0.0f, hiddenByNearerObjects);
|
||||
UtilitiesDXXL_Shapes.Reverse_shapeFillDensity();
|
||||
Reverse_globalTextSizeSpecs();
|
||||
break;
|
||||
case ShapeType.square:
|
||||
Set_globalTextSizeSpecs_reversible();
|
||||
UtilitiesDXXL_Shapes.Set_shapeFillDensity_reversible(shapeFillDensity);
|
||||
DrawBasics2D.Shape(GetDrawPos2D_global(), DrawShapes.Shape2DType.square, Get_size_initialValueUniform(), color, rotation_angleDegCC, Get_linesWidth(), text_inclGlobalMarkupTags, lineStyle, GetZPos_global_for2D(), Get_stylePatternScaleFactor(), fillStyle, textBlockAboveLine, 0.0f, hiddenByNearerObjects);
|
||||
UtilitiesDXXL_Shapes.Reverse_shapeFillDensity();
|
||||
Reverse_globalTextSizeSpecs();
|
||||
break;
|
||||
case ShapeType.pentagon:
|
||||
Set_globalTextSizeSpecs_reversible();
|
||||
UtilitiesDXXL_Shapes.Set_shapeFillDensity_reversible(shapeFillDensity);
|
||||
DrawBasics2D.Shape(GetDrawPos2D_global(), DrawShapes.Shape2DType.pentagon, Get_size_initialValueUniform(), color, rotation_angleDegCC, Get_linesWidth(), text_inclGlobalMarkupTags, lineStyle, GetZPos_global_for2D(), Get_stylePatternScaleFactor(), fillStyle, textBlockAboveLine, 0.0f, hiddenByNearerObjects);
|
||||
UtilitiesDXXL_Shapes.Reverse_shapeFillDensity();
|
||||
Reverse_globalTextSizeSpecs();
|
||||
break;
|
||||
case ShapeType.hexagon:
|
||||
Set_globalTextSizeSpecs_reversible();
|
||||
UtilitiesDXXL_Shapes.Set_shapeFillDensity_reversible(shapeFillDensity);
|
||||
DrawBasics2D.Shape(GetDrawPos2D_global(), DrawShapes.Shape2DType.hexagon, Get_size_initialValueUniform(), color, rotation_angleDegCC, Get_linesWidth(), text_inclGlobalMarkupTags, lineStyle, GetZPos_global_for2D(), Get_stylePatternScaleFactor(), fillStyle, textBlockAboveLine, 0.0f, hiddenByNearerObjects);
|
||||
UtilitiesDXXL_Shapes.Reverse_shapeFillDensity();
|
||||
Reverse_globalTextSizeSpecs();
|
||||
break;
|
||||
case ShapeType.septagon:
|
||||
Set_globalTextSizeSpecs_reversible();
|
||||
UtilitiesDXXL_Shapes.Set_shapeFillDensity_reversible(shapeFillDensity);
|
||||
DrawBasics2D.Shape(GetDrawPos2D_global(), DrawShapes.Shape2DType.septagon, Get_size_initialValueUniform(), color, rotation_angleDegCC, Get_linesWidth(), text_inclGlobalMarkupTags, lineStyle, GetZPos_global_for2D(), Get_stylePatternScaleFactor(), fillStyle, textBlockAboveLine, 0.0f, hiddenByNearerObjects);
|
||||
UtilitiesDXXL_Shapes.Reverse_shapeFillDensity();
|
||||
Reverse_globalTextSizeSpecs();
|
||||
break;
|
||||
case ShapeType.octagon:
|
||||
Set_globalTextSizeSpecs_reversible();
|
||||
UtilitiesDXXL_Shapes.Set_shapeFillDensity_reversible(shapeFillDensity);
|
||||
DrawBasics2D.Shape(GetDrawPos2D_global(), DrawShapes.Shape2DType.octagon, Get_size_initialValueUniform(), color, rotation_angleDegCC, Get_linesWidth(), text_inclGlobalMarkupTags, lineStyle, GetZPos_global_for2D(), Get_stylePatternScaleFactor(), fillStyle, textBlockAboveLine, 0.0f, hiddenByNearerObjects);
|
||||
UtilitiesDXXL_Shapes.Reverse_shapeFillDensity();
|
||||
Reverse_globalTextSizeSpecs();
|
||||
break;
|
||||
case ShapeType.decagon:
|
||||
Set_globalTextSizeSpecs_reversible();
|
||||
UtilitiesDXXL_Shapes.Set_shapeFillDensity_reversible(shapeFillDensity);
|
||||
DrawBasics2D.Shape(GetDrawPos2D_global(), DrawShapes.Shape2DType.decagon, Get_size_initialValueUniform(), color, rotation_angleDegCC, Get_linesWidth(), text_inclGlobalMarkupTags, lineStyle, GetZPos_global_for2D(), Get_stylePatternScaleFactor(), fillStyle, textBlockAboveLine, 0.0f, hiddenByNearerObjects);
|
||||
UtilitiesDXXL_Shapes.Reverse_shapeFillDensity();
|
||||
Reverse_globalTextSizeSpecs();
|
||||
break;
|
||||
case ShapeType.dot:
|
||||
DrawBasics2D.Dot(GetDrawPos2D_global(), 0.5f * GetSizeOfIcon(), color, text_inclGlobalMarkupTags, GetZPos_global_for2D(), dotDensity, 0.0f, hiddenByNearerObjects);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CacheSizeScaleFactors()
|
||||
{
|
||||
biggestAbsGlobalSizeComponentOfTransform_ignoringZ = UtilitiesDXXL_Math.GetBiggestAbsComponent_ignoringZ(transform.lossyScale);
|
||||
cameraForSizeDefinitionIsAvailable = false;
|
||||
switch (sizeDefinition)
|
||||
{
|
||||
case ShapeSizeDefinition.relativeToGlobalScaleOfTheTransformUsingTheBiggestAbsoluteComponentButIgnoringZ:
|
||||
lengthOfScreenDiagonal_atDrawnObjectsPosition = 1.0f;
|
||||
break;
|
||||
case ShapeSizeDefinition.absoluteUnits:
|
||||
lengthOfScreenDiagonal_atDrawnObjectsPosition = 1.0f;
|
||||
break;
|
||||
case ShapeSizeDefinition.relativeToTheSceneViewWindowSize:
|
||||
#if UNITY_EDITOR
|
||||
if (UnityEditor.SceneView.lastActiveSceneView != null)
|
||||
{
|
||||
cameraForSizeDefinitionIsAvailable = true;
|
||||
float distance_ofDrawnObject_toCamera = (GetDrawPos3D_ofA2DModeTransform_global() - UnityEditor.SceneView.lastActiveSceneView.camera.transform.position).magnitude;
|
||||
lengthOfScreenDiagonal_atDrawnObjectsPosition = UtilitiesDXXL_Screenspace.Get_diagonalExtentOfViewport_at_distanceFromCam(UnityEditor.SceneView.lastActiveSceneView.camera, distance_ofDrawnObject_toCamera);
|
||||
}
|
||||
else
|
||||
{
|
||||
lengthOfScreenDiagonal_atDrawnObjectsPosition = 1.0f;
|
||||
}
|
||||
#else
|
||||
lengthOfScreenDiagonal_atDrawnObjectsPosition = 1.0f;
|
||||
#endif
|
||||
break;
|
||||
case ShapeSizeDefinition.relativeToTheGameViewWindowSize:
|
||||
cameraForSizeDefinitionIsAvailable = UtilitiesDXXL_Screenspace.GetAutomaticCameraForDrawing(out gameviewCameraForDrawing, "Shape Drawer 2D Component", false);
|
||||
if (cameraForSizeDefinitionIsAvailable)
|
||||
{
|
||||
float distance_ofDrawnObject_toCamera = (GetDrawPos3D_ofA2DModeTransform_global() - gameviewCameraForDrawing.transform.position).magnitude;
|
||||
lengthOfScreenDiagonal_atDrawnObjectsPosition = UtilitiesDXXL_Screenspace.Get_diagonalExtentOfViewport_at_distanceFromCam(gameviewCameraForDrawing, distance_ofDrawnObject_toCamera);
|
||||
}
|
||||
else
|
||||
{
|
||||
lengthOfScreenDiagonal_atDrawnObjectsPosition = 1.0f;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
lengthOfScreenDiagonal_atDrawnObjectsPosition = 1.0f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
float GetRadius()
|
||||
{
|
||||
return ScaleInputFloat_accordingToSizeDefinition(radiusScaleFactor);
|
||||
}
|
||||
|
||||
float GetSizeOfIcon()
|
||||
{
|
||||
return ScaleInputFloat_accordingToSizeDefinition(sizeOfIconScaleFactor);
|
||||
}
|
||||
|
||||
float Get_width_initialValue1()
|
||||
{
|
||||
return ScaleInputFloat_accordingToSizeDefinition(width_scaleFactor_initialValue1);
|
||||
}
|
||||
|
||||
float Get_height_initialValue1()
|
||||
{
|
||||
return ScaleInputFloat_accordingToSizeDefinition(height_scaleFactor_initialValue1);
|
||||
}
|
||||
|
||||
Vector2 Get_size_initialValueUniform()
|
||||
{
|
||||
return new Vector2(Get_width_initialValue1(), Get_height_initialValue1());
|
||||
}
|
||||
|
||||
float Get_height_initialValue2()
|
||||
{
|
||||
return ScaleInputFloat_accordingToSizeDefinition(height_scaleFactor_initialValue2);
|
||||
}
|
||||
|
||||
Vector2 Get_size_initialValueNonUniform()
|
||||
{
|
||||
return new Vector2(Get_width_initialValue1(), Get_height_initialValue2());
|
||||
}
|
||||
|
||||
float Get_linesWidth()
|
||||
{
|
||||
return ScaleInputFloat_accordingToSizeDefinition(linesWidth);
|
||||
}
|
||||
|
||||
float Get_stylePatternScaleFactor()
|
||||
{
|
||||
float stylePatternScaleFactor_unclamped = ScaleInputFloat_accordingToSizeDefinition(stylePatternScaleFactor);
|
||||
return Mathf.Max(stylePatternScaleFactor_unclamped, UtilitiesDXXL_LineStyles.minStylePatternScaleFactor);
|
||||
}
|
||||
|
||||
float ScaleInputFloat_accordingToSizeDefinition(float inputFloatToScale_versionThatIsRelToScreen, float inputFloatToScale)
|
||||
{
|
||||
switch (sizeDefinition)
|
||||
{
|
||||
case ShapeSizeDefinition.relativeToGlobalScaleOfTheTransformUsingTheBiggestAbsoluteComponentButIgnoringZ:
|
||||
return biggestAbsGlobalSizeComponentOfTransform_ignoringZ * inputFloatToScale;
|
||||
case ShapeSizeDefinition.absoluteUnits:
|
||||
return inputFloatToScale;
|
||||
case ShapeSizeDefinition.relativeToTheSceneViewWindowSize:
|
||||
if (cameraForSizeDefinitionIsAvailable)
|
||||
{
|
||||
return lengthOfScreenDiagonal_atDrawnObjectsPosition * inputFloatToScale_versionThatIsRelToScreen;
|
||||
}
|
||||
else
|
||||
{
|
||||
return inputFloatToScale;
|
||||
}
|
||||
case ShapeSizeDefinition.relativeToTheGameViewWindowSize:
|
||||
if (cameraForSizeDefinitionIsAvailable)
|
||||
{
|
||||
return lengthOfScreenDiagonal_atDrawnObjectsPosition * inputFloatToScale_versionThatIsRelToScreen;
|
||||
}
|
||||
else
|
||||
{
|
||||
return inputFloatToScale;
|
||||
}
|
||||
default:
|
||||
return inputFloatToScale;
|
||||
}
|
||||
}
|
||||
|
||||
float ScaleInputFloat_accordingToSizeDefinition(ScreenRelativeValue value)
|
||||
{
|
||||
return ScaleInputFloat_accordingToSizeDefinition(value.relativeToScreen, value.absolute);
|
||||
}
|
||||
|
||||
float forcedConstantScreenspaceTextSize_relToScreenHeight_forTextAtShapes_before;
|
||||
float forcedConstantWorldspaceTextSize_forTextAtShapes_before;
|
||||
DrawBasics.CameraForAutomaticOrientation cameraForAutomaticOrientation_before;
|
||||
DrawText.AutomaticTextOrientation automaticTextOrientation_before;
|
||||
void Set_globalTextSizeSpecs_reversible()
|
||||
{
|
||||
forcedConstantScreenspaceTextSize_relToScreenHeight_forTextAtShapes_before = DrawShapes.forcedConstantScreenspaceTextSize_relToScreenHeight_forTextAtShapes;
|
||||
forcedConstantWorldspaceTextSize_forTextAtShapes_before = DrawShapes.forcedConstantWorldspaceTextSize_forTextAtShapes;
|
||||
cameraForAutomaticOrientation_before = DrawBasics.cameraForAutomaticOrientation;
|
||||
automaticTextOrientation_before = DrawText.automaticTextOrientation;
|
||||
|
||||
if (sizeDefinition == ShapeSizeDefinition.relativeToTheSceneViewWindowSize)
|
||||
{
|
||||
DrawBasics.cameraForAutomaticOrientation = DrawBasics.CameraForAutomaticOrientation.sceneViewCamera;
|
||||
DrawText.automaticTextOrientation = DrawText.AutomaticTextOrientation.screen;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sizeDefinition == ShapeSizeDefinition.relativeToTheGameViewWindowSize)
|
||||
{
|
||||
DrawBasics.cameraForAutomaticOrientation = DrawBasics.CameraForAutomaticOrientation.gameViewCamera;
|
||||
DrawText.automaticTextOrientation = DrawText.AutomaticTextOrientation.screen;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (shapeAttachedTextsizeReferenceContext)
|
||||
{
|
||||
case ShapeDrawer.ShapeAttachedTextsizeReferenceContext.sizeOfShape:
|
||||
DrawShapes.forcedConstantScreenspaceTextSize_relToScreenHeight_forTextAtShapes = 0.0f;
|
||||
DrawShapes.forcedConstantWorldspaceTextSize_forTextAtShapes = 0.0f;
|
||||
break;
|
||||
case ShapeDrawer.ShapeAttachedTextsizeReferenceContext.globalSpace:
|
||||
DrawShapes.forcedConstantScreenspaceTextSize_relToScreenHeight_forTextAtShapes = 0.0f;
|
||||
DrawShapes.forcedConstantWorldspaceTextSize_forTextAtShapes = textSize_value;
|
||||
break;
|
||||
case ShapeDrawer.ShapeAttachedTextsizeReferenceContext.sceneViewWindowSize:
|
||||
DrawShapes.forcedConstantScreenspaceTextSize_relToScreenHeight_forTextAtShapes = textSize_value_relToScreen;
|
||||
DrawShapes.forcedConstantWorldspaceTextSize_forTextAtShapes = 0.0f;
|
||||
DrawBasics.cameraForAutomaticOrientation = DrawBasics.CameraForAutomaticOrientation.sceneViewCamera;
|
||||
DrawText.automaticTextOrientation = DrawText.AutomaticTextOrientation.screen;
|
||||
break;
|
||||
case ShapeDrawer.ShapeAttachedTextsizeReferenceContext.gameViewWindowSize:
|
||||
DrawShapes.forcedConstantScreenspaceTextSize_relToScreenHeight_forTextAtShapes = textSize_value_relToScreen;
|
||||
DrawShapes.forcedConstantWorldspaceTextSize_forTextAtShapes = 0.0f;
|
||||
DrawBasics.cameraForAutomaticOrientation = DrawBasics.CameraForAutomaticOrientation.gameViewCamera;
|
||||
DrawText.automaticTextOrientation = DrawText.AutomaticTextOrientation.screen;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Reverse_globalTextSizeSpecs()
|
||||
{
|
||||
DrawShapes.forcedConstantScreenspaceTextSize_relToScreenHeight_forTextAtShapes = forcedConstantScreenspaceTextSize_relToScreenHeight_forTextAtShapes_before;
|
||||
DrawShapes.forcedConstantWorldspaceTextSize_forTextAtShapes = forcedConstantWorldspaceTextSize_forTextAtShapes_before;
|
||||
DrawBasics.cameraForAutomaticOrientation = cameraForAutomaticOrientation_before;
|
||||
DrawText.automaticTextOrientation = automaticTextOrientation_before;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48d0fe42b7a205a48b4d85c8c91c8486
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,221 @@
|
||||
namespace DrawXXL
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
[HelpURL("https://www.symphonygames.net/drawxxldocumentation/index.html")]
|
||||
[AddComponentMenu("Xeric Library/DebugDrawLibrary/2D/Tag Drawer 2D")]
|
||||
[DefaultExecutionOrder(31000)] //negative numers are early, positive numbers are late. Range is till 32000 to both negative and positive direction.
|
||||
public class TagDrawer2D : VisualizerParent
|
||||
{
|
||||
[SerializeField] float linesWidth = 0.0f;
|
||||
[SerializeField] [Range(0.0f, 0.02f)] float linesWidth_relToScreen = 0.0f;
|
||||
[SerializeField] Color color = DrawBasics.defaultColor;
|
||||
[SerializeField] bool drawGlobalCoordinates = false;
|
||||
[SerializeField] [Range(0.0f, 1.0f)] float strokeWidth_forCoordinateTexts_onPointVisualiation_in0to1 = 0.0f;
|
||||
[SerializeField] float sizeOfMarkingCross = 1.0f;
|
||||
[SerializeField] [Range(0.005f, 1.0f)] float sizeOfMarkingCross_relToScreen = 0.1f;
|
||||
[SerializeField] bool skipConeDrawing = false;
|
||||
[SerializeField] bool forcePointerDirection = false;
|
||||
[SerializeField] float pointerTextSize_value = 0.1f;
|
||||
[SerializeField] [Range(0.001f, 0.3f)] float pointerTextSize_value_relToScreen = 0.01f;
|
||||
[SerializeField] public bool textOffsetDistance_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] float textOffsetDistance = 1.0f;
|
||||
[SerializeField] [Range(0.0025f, 0.2f)] float textOffsetDistance_relToScreen = 0.1f;
|
||||
[SerializeField] TagDrawer.PointerSizeInterpretation pointerSizeInterpretation = TagDrawer.PointerSizeInterpretation.absoluteUnits;
|
||||
[SerializeField] TagDrawer.AttachedTextsizeReferenceContext attachedTextsizeReferenceContext = TagDrawer.AttachedTextsizeReferenceContext.sceneViewWindowSize;
|
||||
float lengthOfScreenDiagonal_atDrawnObjectsPosition = 1.0f;
|
||||
float biggestAbsGlobalSizeComponentOfTransform_ignoringZ = 1.0f;
|
||||
[SerializeField] bool cameraForSizeDefinitionIsAvailable = false;
|
||||
Camera gameviewCameraForDrawing;
|
||||
|
||||
public override void InitializeValues_onceInComponentLifetime()
|
||||
{
|
||||
if (text_exclGlobalMarkupTags == null || text_exclGlobalMarkupTags == "")
|
||||
{
|
||||
text_exclGlobalMarkupTags = "tag text of " + this.gameObject.name;
|
||||
text_inclGlobalMarkupTags = "tag text of " + this.gameObject.name;
|
||||
}
|
||||
textSection_isOutfolded = true;
|
||||
|
||||
customVector2Configs[0].source = CustomVector2Source.manualInput;
|
||||
customVector2Configs[0].clipboardForManualInput = (-DrawBasics.Default_textOffsetDirection_forPointTags);
|
||||
customVector2Configs[0].vectorInterpretation = VectorInterpretation.globalSpace;
|
||||
}
|
||||
|
||||
public override void DrawVisualizedObject()
|
||||
{
|
||||
CacheSizeScaleFactors();
|
||||
Vector2 drawPos2D_global = GetDrawPos2D_global();
|
||||
TryDrawCoordinates(drawPos2D_global);
|
||||
Vector2 used_textOffsetDir = forcePointerDirection ? (-Get_customVector2_1_inGlobalSpaceUnits()) : Vector2.zero;
|
||||
float used_linesWidth = ScaleInputFloat_accordingToSizeDefinition(linesWidth_relToScreen, linesWidth);
|
||||
float used_textOffsetDistance_unclamped = ScaleInputFloat_accordingToSizeDefinition(textOffsetDistance_relToScreen, textOffsetDistance);
|
||||
float used_textOffsetDistance = UtilitiesDXXL_DrawBasics.GetClamped_pointTagSize_asTextOffsetDistance(used_textOffsetDistance_unclamped, used_linesWidth);
|
||||
float used_relTextSizeScaling = Get_used_relTextSizeScaling(used_textOffsetDistance);
|
||||
DrawBasics2D.PointTag(drawPos2D_global, text_inclGlobalMarkupTags, color, used_linesWidth, used_textOffsetDistance, used_textOffsetDir, GetZPos_global_for2D(), used_relTextSizeScaling, skipConeDrawing, 0.0f, hiddenByNearerObjects);
|
||||
}
|
||||
|
||||
void CacheSizeScaleFactors()
|
||||
{
|
||||
biggestAbsGlobalSizeComponentOfTransform_ignoringZ = UtilitiesDXXL_Math.GetBiggestAbsComponent_ignoringZ(transform.lossyScale);
|
||||
cameraForSizeDefinitionIsAvailable = false;
|
||||
switch (pointerSizeInterpretation)
|
||||
{
|
||||
case TagDrawer.PointerSizeInterpretation.absoluteUnits:
|
||||
lengthOfScreenDiagonal_atDrawnObjectsPosition = 1.0f;
|
||||
break;
|
||||
case TagDrawer.PointerSizeInterpretation.relativeToGameobjectSize:
|
||||
lengthOfScreenDiagonal_atDrawnObjectsPosition = 1.0f;
|
||||
break;
|
||||
case TagDrawer.PointerSizeInterpretation.relativeToTheSceneViewWindowSize:
|
||||
#if UNITY_EDITOR
|
||||
if (UnityEditor.SceneView.lastActiveSceneView != null)
|
||||
{
|
||||
cameraForSizeDefinitionIsAvailable = true;
|
||||
float distance_ofDrawnObject_toCamera = (GetDrawPos3D_ofA2DModeTransform_global() - UnityEditor.SceneView.lastActiveSceneView.camera.transform.position).magnitude;
|
||||
lengthOfScreenDiagonal_atDrawnObjectsPosition = UtilitiesDXXL_Screenspace.Get_diagonalExtentOfViewport_at_distanceFromCam(UnityEditor.SceneView.lastActiveSceneView.camera, distance_ofDrawnObject_toCamera);
|
||||
}
|
||||
else
|
||||
{
|
||||
lengthOfScreenDiagonal_atDrawnObjectsPosition = 1.0f;
|
||||
}
|
||||
#else
|
||||
lengthOfScreenDiagonal_atDrawnObjectsPosition = 1.0f;
|
||||
#endif
|
||||
break;
|
||||
case TagDrawer.PointerSizeInterpretation.relativeToTheGameViewWindowSize:
|
||||
cameraForSizeDefinitionIsAvailable = UtilitiesDXXL_Screenspace.GetAutomaticCameraForDrawing(out gameviewCameraForDrawing, "Tag Drawer 2D Component", false);
|
||||
if (cameraForSizeDefinitionIsAvailable)
|
||||
{
|
||||
float distance_ofDrawnObject_toCamera = (GetDrawPos3D_ofA2DModeTransform_global() - gameviewCameraForDrawing.transform.position).magnitude;
|
||||
lengthOfScreenDiagonal_atDrawnObjectsPosition = UtilitiesDXXL_Screenspace.Get_diagonalExtentOfViewport_at_distanceFromCam(gameviewCameraForDrawing, distance_ofDrawnObject_toCamera);
|
||||
}
|
||||
else
|
||||
{
|
||||
lengthOfScreenDiagonal_atDrawnObjectsPosition = 1.0f;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
lengthOfScreenDiagonal_atDrawnObjectsPosition = 1.0f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void TryDrawCoordinates(Vector2 drawPos2D_global)
|
||||
{
|
||||
if (drawGlobalCoordinates)
|
||||
{
|
||||
UtilitiesDXXL_DrawBasics.Set_strokeWidth_forCoordinateTexts_onPointVisualiation_inPPM_reversible(Convert_strokeWidthForCoordinateTexts_toPPM());
|
||||
DrawBasics2D.Point(drawPos2D_global, null, default(Color), ScaleInputFloat_accordingToSizeDefinition(sizeOfMarkingCross_relToScreen, sizeOfMarkingCross), 0.0f, GetZPos_global_for2D(), default(Color), 0.0f, false, true, 0.0f, hiddenByNearerObjects);
|
||||
UtilitiesDXXL_DrawBasics.Reverse_strokeWidth_forCoordinateTexts_onPointVisualiation_inPPM();
|
||||
}
|
||||
}
|
||||
|
||||
int Convert_strokeWidthForCoordinateTexts_toPPM()
|
||||
{
|
||||
if (strokeWidth_forCoordinateTexts_onPointVisualiation_in0to1 <= 0.0f)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Mathf.CeilToInt(strokeWidth_forCoordinateTexts_onPointVisualiation_in0to1 * UtilitiesDXXL_Text.maxRelStrokeWidth_inPPMofSize);
|
||||
}
|
||||
}
|
||||
|
||||
float Get_used_relTextSizeScaling(float used_textOffsetDistance)
|
||||
{
|
||||
if (CheckIf_pointerSizeInterpretaion_isDependentOn_screenspace() == false)
|
||||
{
|
||||
switch (attachedTextsizeReferenceContext)
|
||||
{
|
||||
case TagDrawer.AttachedTextsizeReferenceContext.extentOfTag:
|
||||
return 1.0f;
|
||||
case TagDrawer.AttachedTextsizeReferenceContext.globalSpace:
|
||||
return Get_used_relTextSizeScaling_toReachAFixedWorldSpaceTextSize(pointerTextSize_value, used_textOffsetDistance);
|
||||
case TagDrawer.AttachedTextsizeReferenceContext.sceneViewWindowSize:
|
||||
//cannot reuse "cameraForSizeDefinitionIsAvailable" here, since "pointerAttachedTextsizeReferenceContext" is another setting than "pointerSizeInterpretation"
|
||||
#if UNITY_EDITOR
|
||||
if (UnityEditor.SceneView.lastActiveSceneView != null)
|
||||
{
|
||||
float distance_ofDrawnObject_toCamera = (GetDrawPos3D_ofA2DModeTransform_global() - UnityEditor.SceneView.lastActiveSceneView.camera.transform.position).magnitude;
|
||||
float lengthOfScreenDiagonal_atDrawnObjectsPosition = UtilitiesDXXL_Screenspace.Get_diagonalExtentOfViewport_at_distanceFromCam(UnityEditor.SceneView.lastActiveSceneView.camera, distance_ofDrawnObject_toCamera);
|
||||
float worldSpaceTextSize_toReachWantedScreenspaceTextSize = lengthOfScreenDiagonal_atDrawnObjectsPosition * pointerTextSize_value_relToScreen;
|
||||
return Get_used_relTextSizeScaling_toReachAFixedWorldSpaceTextSize(worldSpaceTextSize_toReachWantedScreenspaceTextSize, used_textOffsetDistance);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
#else
|
||||
return 1.0f;
|
||||
#endif
|
||||
case TagDrawer.AttachedTextsizeReferenceContext.gameViewWindowSize:
|
||||
//cannot reuse "cameraForSizeDefinitionIsAvailable" here, since "pointerAttachedTextsizeReferenceContext" is another setting than "pointerSizeInterpretation"
|
||||
bool cameraForTextSizeDefinitionIsAvailable = UtilitiesDXXL_Screenspace.GetAutomaticCameraForDrawing(out gameviewCameraForDrawing, "Tag Drawer Component", false);
|
||||
if (cameraForTextSizeDefinitionIsAvailable)
|
||||
{
|
||||
float distance_ofDrawnObject_toCamera = (GetDrawPos3D_ofA2DModeTransform_global() - gameviewCameraForDrawing.transform.position).magnitude;
|
||||
float lengthOfScreenDiagonal_atDrawnObjectsPosition = UtilitiesDXXL_Screenspace.Get_diagonalExtentOfViewport_at_distanceFromCam(gameviewCameraForDrawing, distance_ofDrawnObject_toCamera);
|
||||
float worldSpaceTextSize_toReachWantedScreenspaceTextSize = lengthOfScreenDiagonal_atDrawnObjectsPosition * pointerTextSize_value_relToScreen;
|
||||
return Get_used_relTextSizeScaling_toReachAFixedWorldSpaceTextSize(worldSpaceTextSize_toReachWantedScreenspaceTextSize, used_textOffsetDistance);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
default:
|
||||
return 1.0f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
float Get_used_relTextSizeScaling_toReachAFixedWorldSpaceTextSize(float fixedWorldSpaceTextSize_toReach, float used_textOffsetDistance)
|
||||
{
|
||||
//"used_textOffsetDistance" is guaranteed bigger than 0 here -> no "division by 0" check necessary
|
||||
return (fixedWorldSpaceTextSize_toReach / (used_textOffsetDistance * UtilitiesDXXL_DrawBasics.pointTagsTextSize_relToOffset));
|
||||
}
|
||||
|
||||
bool CheckIf_pointerSizeInterpretaion_isDependentOn_screenspace()
|
||||
{
|
||||
return ((pointerSizeInterpretation == TagDrawer.PointerSizeInterpretation.relativeToTheSceneViewWindowSize) || (pointerSizeInterpretation == TagDrawer.PointerSizeInterpretation.relativeToTheGameViewWindowSize));
|
||||
}
|
||||
|
||||
float ScaleInputFloat_accordingToSizeDefinition(float inputFloatToScale_versionThatIsRelToScreen, float inputFloatToScale)
|
||||
{
|
||||
switch (pointerSizeInterpretation)
|
||||
{
|
||||
case TagDrawer.PointerSizeInterpretation.absoluteUnits:
|
||||
return inputFloatToScale;
|
||||
case TagDrawer.PointerSizeInterpretation.relativeToGameobjectSize:
|
||||
return biggestAbsGlobalSizeComponentOfTransform_ignoringZ * inputFloatToScale;
|
||||
case TagDrawer.PointerSizeInterpretation.relativeToTheSceneViewWindowSize:
|
||||
if (cameraForSizeDefinitionIsAvailable)
|
||||
{
|
||||
return lengthOfScreenDiagonal_atDrawnObjectsPosition * inputFloatToScale_versionThatIsRelToScreen;
|
||||
}
|
||||
else
|
||||
{
|
||||
return inputFloatToScale;
|
||||
}
|
||||
case TagDrawer.PointerSizeInterpretation.relativeToTheGameViewWindowSize:
|
||||
if (cameraForSizeDefinitionIsAvailable)
|
||||
{
|
||||
return lengthOfScreenDiagonal_atDrawnObjectsPosition * inputFloatToScale_versionThatIsRelToScreen;
|
||||
}
|
||||
else
|
||||
{
|
||||
return inputFloatToScale;
|
||||
}
|
||||
default:
|
||||
return inputFloatToScale;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca3f9a25118722445b01b0d8c9081b04
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,51 @@
|
||||
namespace DrawXXL
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
[HelpURL("https://www.symphonygames.net/drawxxldocumentation/index.html")]
|
||||
[AddComponentMenu("Xeric Library/DebugDrawLibrary/2D/Text Drawer 2D")]
|
||||
public class TextDrawer2D : TextDrawer
|
||||
{
|
||||
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.transformsRight;
|
||||
customVector2Configs[0].clipboardForManualInput = Vector2.right;
|
||||
customVector2Configs[0].vectorInterpretation = VectorInterpretation.globalSpace;
|
||||
}
|
||||
|
||||
public override void DrawVisualizedObject()
|
||||
{
|
||||
CacheSizeScaleFactors("Text Drawer 2D Component");
|
||||
float used_size = Get_used_size();
|
||||
if (text_inclGlobalMarkupTags != null && text_inclGlobalMarkupTags != "")
|
||||
{
|
||||
if (UtilitiesDXXL_Math.ApproximatelyZero(used_size) == false)
|
||||
{
|
||||
GetScaledTextBlockConstraintValues(out float used_forceTextEnlargementToThisMinWidth_value, out float used_forceRestrictTextSizeToThisMaxTextWidth_value, out float used_autoLineBreakWidth_value);
|
||||
Vector2 textDir = Get_customVector2_1_inGlobalSpaceUnits();
|
||||
UtilitiesDXXL_Text.Write2DFramed(text_inclGlobalMarkupTags, GetDrawPos2D_global(), color, used_size, textDir, textAnchor, GetZPos_global_for2D(), enclosingBoxLineStyle, enclosingBox_lineWidth_relToTextSize, enclosingBox_paddingSize_relToTextSize, used_forceTextEnlargementToThisMinWidth_value, used_forceRestrictTextSizeToThisMaxTextWidth_value, used_autoLineBreakWidth_value, autoFlipToPreventMirrorInverted, 0.0f, hiddenByNearerObjects);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override float Get_biggestAbsGlobalSizeComponentOfTransform()
|
||||
{
|
||||
return UtilitiesDXXL_Math.GetBiggestAbsComponent_ignoringZ(transform.lossyScale);
|
||||
}
|
||||
|
||||
public override Vector3 Get_used_drawPos3D_global()
|
||||
{
|
||||
return GetDrawPos3D_ofA2DModeTransform_global();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f28f48059dc6a1a4dac5118f2bc8f106
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user