共用方式為


InteractionTracker.NaturalRestingPosition 屬性

定義

InteractionTracker的自然靜止位置。

NaturalRestingPosition 屬性是 InteractionTracker 不會考慮界限或慣性修飾詞的計算位置。 此屬性通常適用于捲動體驗中的虛擬化等動作,其中請務必知道 InteractionTracker 停止的位置。 使用 NaturalRestingPosition 屬性有兩個主要使用案例:在 InertiaStateEntered 事件引數中擷取其目前值,或在 ExpressionAnimation 中建立慣性修飾詞之類的專案時參考此屬性。

public:
 property float3 NaturalRestingPosition { float3 get(); };
float3 NaturalRestingPosition();
public Vector3 NaturalRestingPosition { get; }
var vector3 = interactionTracker.naturalRestingPosition;
Public ReadOnly Property NaturalRestingPosition As Vector3

屬性值

Vector3 Vector3

float3

InteractionTracker的自然靜止位置。

範例

// Listen for the InertiaStateEntered event, so can grab NaturalRestingPosition value.
public void InertiaStateEntered(InteractionTracker sender, InteractionTrackerInertiaStateEnteredArgs args)
{
  // Grab the NaturalRestingPosition out of the args when the event is fired. Now have access to calculated Natural Rest spot
  Vector3 naturalRest = args.NaturalRestingPosition;
}

// Reference the NaturalRestingPosition property in an expression for things like 	SnapPoints
void CreateBasicSnapPoint(float highBound, float lowBound)
{
  var snappoint = InteractionTrackerInertiaRestingValue.Create(_compositor);

  // Reference the NaturalRestingPosition of InteractionTracker in an ExpressionAnimation for conditional portion of an InertiaModifier.
  snappoint.Condition = _compositor.CreateExpressionAnimation("this.target.NaturalRestingPosition.Y >= 	lowBound && this.target.NaturalRestingPosition.Y < highBound ");

  snappoint.Condition.SetScalarParameter("lowBound", lowBound);
  snappoint.Condition.SetScalarParameter("highBound", highBound);

  // Snap to the highbound if condition met
  snappoint.RestingValue = _compositor.CreateExpressionAnimation("highBound");
  snappoint.RestingValue.SetScalarParameter("highBound", highBound);

  yInertiaModifier.Add(snappoint);

  _tracker.ConfigurePositionYInertiaModifiers(yInertiaModifier);
}

備註

上述程式碼片段中所述的兩個使用案例是 NaturalRestingPosition 屬性的主要用途。 雖然您可能想要像任何其他 object.property 關聯性一樣參考這個屬性,但 不一定會取得最新的值。 在此情況下,建議您接聽 InertiaStateEntered 事件,並從引數擷取最新的值。

適用於