public static AttachTransform Attach(GameObject target, Transform attachment, bool flipped, bool lockRotation, bool lockX = false, HeightLock lockY = HeightLock.Unlocked, bool lockZ = false) { AttachTransform at = target.GetComponent <AttachTransform>(); if (at == null) { at = target.AddComponent <AttachTransform>(); } // Note: Ideally child rot and child position should be passed in, and not recalculated by applying the inverses. It's unnecessary. at._attachment = attachment; at._startChildRotation = Quaternion.Inverse(attachment.rotation) * target.transform.rotation; at._startChildPosition = attachment.InverseTransformPoint(target.transform.position); at._startChildWorldPosition = target.transform.position; #if UNITY_EDITOR at._attached = true; #endif at._flipped = flipped; at._lockRotation = lockRotation; at._lockXOffset = lockX; at._lockYOffset = lockY; at._lockZOffset = lockZ; at.UpdateAttachment(); return(at); }
private void UpdateTrailRenderer() { #if UNITY_EDITOR UpdateValues(); if (_TimeUnits == TrailRenderer.eTIME_UNITS.Frames) { ConvertFramesToSeconds(); } trailRenderer._TrailTime = _TrailTime; #endif // TJ: Update our attach transform before updating trail if (_AttachTransform != null) { _AttachTransform.UpdateAttachment(); } if (!trailRenderer.Update(pauseOffset)) { Stop(); } }