You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CrowdControl/Assets/3rd/D2D_Scripts/Camera/Scripts/AttachSelfToCameraOnStart.cs

25 lines
594 B
C#

using UnityEngine;
namespace D2D.Cameras
{
public class AttachSelfToCameraOnStart : MonoBehaviour
{
[SerializeField] private bool _isZeroLocalPosition = true;
[SerializeField] private Vector3 swift;
private void Start()
{
var cam = FindObjectOfType<Camera>();
transform.parent = cam.transform;
if (_isZeroLocalPosition)
{
transform.localPosition = Vector3.zero;
}
else
{
transform.localPosition = swift;
}
}
}
}