File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Assets/HoloToolkit/Utilities/Scripts Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,16 @@ public class Billboard : MonoBehaviour
2424 [ Tooltip ( "Specifies the axis about which the object will rotate." ) ]
2525 public PivotAxis PivotAxis = PivotAxis . Free ;
2626
27+ [ Tooltip ( "Specifies the target we will orient to. If no Target is specified the main camera will be used." ) ]
28+ public Transform TargetTransform ;
29+
2730 private void OnEnable ( )
2831 {
32+ if ( TargetTransform == null )
33+ {
34+ TargetTransform = Camera . main . transform ;
35+ }
36+
2937 Update ( ) ;
3038 }
3139
@@ -34,13 +42,13 @@ private void OnEnable()
3442 /// </summary>
3543 private void Update ( )
3644 {
37- if ( ! Camera . main )
45+ if ( TargetTransform == null )
3846 {
3947 return ;
4048 }
4149
4250 // Get a Vector that points from the target to the main camera.
43- Vector3 directionToTarget = Camera . main . transform . position - transform . position ;
51+ Vector3 directionToTarget = TargetTransform . position - transform . position ;
4452
4553 // Adjust for the pivot axis.
4654 switch ( PivotAxis )
@@ -65,4 +73,4 @@ private void Update()
6573 transform . rotation = Quaternion . LookRotation ( - directionToTarget ) ;
6674 }
6775 }
68- }
76+ }
You can’t perform that action at this time.
0 commit comments