forked from Shardstone/trail-into-darkness
changed directory structure
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Jovian.Utilities {
|
||||
[RequireComponent(typeof(Canvas))]
|
||||
public class CanvasAutoAssignWorldCamera : MonoBehaviour {
|
||||
public Canvas canvas;
|
||||
public bool autoDisableOnceCameraFound = false;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public void Reset() {
|
||||
SerializedObjectUtility.SaveObjectProperties(this, nameof(canvas), GetComponent<Canvas>());
|
||||
}
|
||||
#endif
|
||||
|
||||
private void Update() {
|
||||
if(canvas && !canvas.worldCamera) {
|
||||
canvas.worldCamera = CachedMainCamera.MainCamera;
|
||||
if(canvas.worldCamera && autoDisableOnceCameraFound) {
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user