/// <summary> /// Clears all sources and adds a new source with transform. /// </summary> /// <returns>The new constraint.</returns> public static ConstraintSource SetSource(this IConstraint constraint, Transform transform) { ConstraintSource source = new ConstraintSource(); source.sourceTransform = transform; source.weight = 1; constraint.SetSources(new List <ConstraintSource>()); constraint.AddSource(source); return(source); }
public static int AddSourceAndSetActive( this IConstraint constraint, Transform sourceTransform, float weight = 1f, bool activeState = true) { int sourceIndex = constraint.AddSource( new ConstraintSource { sourceTransform = sourceTransform, weight = weight }); constraint.constraintActive = activeState; return(sourceIndex); }