Created
January 13, 2020 21:41
-
-
Save SnugglePilot/0a23b8905e3b90404b274f3987313d5a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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