Skip to content

Instantly share code, notes, and snippets.

@SnugglePilot
Created January 13, 2020 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SnugglePilot/0a23b8905e3b90404b274f3987313d5a to your computer and use it in GitHub Desktop.
Save SnugglePilot/0a23b8905e3b90404b274f3987313d5a to your computer and use it in GitHub Desktop.
using UnityEngine;
namespace absurdjoy
{
public struct TransformValues
{
public Vector3 position;
public Quaternion rotation;
public TransformValues(Vector3 position, Quaternion rotation)
{
this.position = position;
this.rotation = rotation;
}
public void ApplyTo(Transform target, bool localSpace)
{
if (localSpace)
{
target.localPosition = position;
target.localRotation = rotation;
}
else
{
target.position = position;
target.rotation = rotation;
}
}
public static TransformValues FromTransform(Transform target, bool localSpace)
{
if (localSpace)
{
return new TransformValues(target.localPosition, target.localRotation);
}
else
{
return new TransformValues(target.position, target.rotation);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment