Created
September 9, 2019 05:35
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 Chigusa | |
{ | |
/// <summary> | |
/// 回転を打ち消す | |
/// (スプライトなどで常に正面を向かせるなど) | |
/// </summary> | |
[ExecuteInEditMode] | |
[DisallowMultipleComponent] | |
public class RotationCancel : MonoBehaviour | |
{ | |
[Tooltip("Edit中にも反映させる")] | |
public bool executeInEditMode = true; | |
/// <summary> | |
/// Update | |
/// </summary> | |
void Update() | |
{ | |
#if UNITY_EDITOR | |
if (!executeInEditMode) | |
return; | |
#endif | |
// 打ち消す | |
if (transform.parent) | |
transform.localRotation = Quaternion.Inverse(transform.parent.rotation); | |
else | |
transform.localRotation = Quaternion.identity; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment