SpringPosition.Begin C# (CSharp) Méthode

Begin() static public méthode

Start the tweening process.
static public Begin ( GameObject go, Vector3 pos, float strength ) : SpringPosition,
go GameObject
pos Vector3
strength float
Résultat SpringPosition,
	static public SpringPosition Begin (GameObject go, Vector3 pos, float strength)
	{
		SpringPosition sp = go.GetComponent<SpringPosition>();
		if (sp == null) sp = go.AddComponent<SpringPosition>();
		sp.target = pos;
		sp.strength = strength;
		sp.onFinished = null;

		if (!sp.enabled)
		{
			sp.mThreshold = 0f;
			sp.enabled = true;
		}
		return sp;
	}
}

Usage Example

Exemple #1
0
    /// <summary>
    /// Constrain the current target position to be within panel bounds.
    /// </summary>

    public bool ConstrainTargetToBounds(Transform target, ref Bounds targetBounds, bool immediate)
    {
        Vector3 offset = CalculateConstrainOffset(targetBounds.min, targetBounds.max);

        if (offset.magnitude > 0f)
        {
            if (immediate)
            {
                target.localPosition += offset;
                targetBounds.center  += offset;
                SpringPosition sp = target.GetComponent <SpringPosition>();
                if (sp != null)
                {
                    sp.enabled = false;
                }
            }
            else
            {
                SpringPosition sp = SpringPosition.Begin(target.gameObject, target.localPosition + offset, 13f);
                sp.ignoreTimeScale = true;
                sp.worldSpace      = false;
            }
            return(true);
        }
        return(false);
    }
All Usage Examples Of SpringPosition::Begin