File tree Expand file tree Collapse file tree 3 files changed +41
-34
lines changed
UOP1_Project/Assets/Scripts/Cutscenes Expand file tree Collapse file tree 3 files changed +41
-34
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ using UnityEngine ;
2
+ using UnityEngine . Playables ;
3
+
4
+ public class TimelineBinder : MonoBehaviour
5
+ {
6
+ [ SerializeField ] private PlayableDirector _playableDirector ;
7
+ [ SerializeField ] private GameObject [ ] _objectsToBind ;
8
+ public string [ ] objectsToBindTags ;
9
+ public string [ ] trackNames ;
10
+ [ SerializeField ] private TransformEventChannelSO _playerInstantiatedChannel = default ;
11
+
12
+ private void OnEnable ( )
13
+ {
14
+ _playerInstantiatedChannel . OnEventRaised += BindPlayer ;
15
+ }
16
+ private void OnDisable ( )
17
+ {
18
+ _playerInstantiatedChannel . OnEventRaised -= BindPlayer ;
19
+ }
20
+
21
+ private void BindPlayer ( Transform playerTransform )
22
+ {
23
+ _objectsToBind = new GameObject [ objectsToBindTags . Length ] ;
24
+ for ( int i = 0 ; i < objectsToBindTags . Length ; ++ i )
25
+ {
26
+ _objectsToBind [ i ] = GameObject . FindGameObjectWithTag ( objectsToBindTags [ i ] ) ;
27
+ Debug . Log ( objectsToBindTags [ i ] ) ;
28
+ }
29
+
30
+ foreach ( var playableAssetOutput in _playableDirector . playableAsset . outputs )
31
+ {
32
+ for ( int i = 0 ; i < objectsToBindTags . Length ; ++ i )
33
+ {
34
+ if ( playableAssetOutput . streamName == trackNames [ i ] )
35
+ {
36
+ _playableDirector . SetGenericBinding ( playableAssetOutput . sourceObject , _objectsToBind [ i ] ) ;
37
+ }
38
+ }
39
+ }
40
+ }
41
+ }
File renamed without changes.
You can’t perform that action at this time.
0 commit comments