示例#1
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.H))
     {
         foreach (var track in playableDirector.playableAsset.outputs)
         {
             if (track.streamName == "Attacker Animation")
             {
                 playableDirector.SetGenericBinding(track.sourceObject, attacker);
             }
             else if (track.streamName == "Victim Animation")
             {
                 playableDirector.SetGenericBinding(track.sourceObject, victim);
             }
         }
         playableDirector.Play();
     }
 }
        public override void SetupDataProviders(PlayableDirector director, List <IFunctionalityProvider> providers)
        {
            var providerObj          = GameObjectUtils.Create(k_ProviderName);
            var faceTrackingProvider = providerObj.AddComponent <RecordedFaceTrackingProvider>();

            faceTrackingProvider.SetupFromRecording(this);
            providers.Add(faceTrackingProvider);
            director.SetGenericBinding(m_SignalTrack, providerObj);
        }
示例#3
0
    private void Start()
    {
        //lastAnimTrigger.SetActive(false);
        player   = FirstPersonCamera.player;
        director = GetComponent <PlayableDirector>();
        TimelineAsset asset = director.playableAsset as TimelineAsset;

        director.SetGenericBinding(asset.GetOutputTrack(0), Camera.main.gameObject);
    }
示例#4
0
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.H))
     {
         foreach (var track in pd.playableAsset.outputs)
         {
             if (track.streamName == "Attacker Animator")
             {
                 pd.SetGenericBinding(track.sourceObject, Attacker);
             }
             else if (track.streamName == "Victim Animator")
             {
                 pd.SetGenericBinding(track.sourceObject, Victim);
             }
         }
         pd.Play();
     }
 }
示例#5
0
 public void LaunchDirector(string path)
 {
     Debug.Log("Binding Timeline Tracks!");
     //director.playableAsset = Resources.Load<PlayableAsset>(path);
     director.playableAsset = loader.LoadSync <PlayableAsset>(path);//同步加载??
     foreach (var playableAssetOutput in director.playableAsset.outputs)
     {
         if (playableAssetOutput.streamName == "PlayerAnim")
         {
             director.SetGenericBinding(playableAssetOutput.sourceObject, playerAnim);
         }
         else if (playableAssetOutput.streamName == "BotAnim")
         {
             director.SetGenericBinding(playableAssetOutput.sourceObject, botAnim);
         }
     }
     director.Play();
 }
示例#6
0
 /// <summary>
 /// レースの順位によってプレイヤーをトラックにバインドする処理
 /// </summary>
 public void BindPlayer()
 {
     for (int i = 0; i < GameManager.Instance.playerResultInfos.Count; i++)
     {
         var PlayerNo       = GameManager.Instance.playerResultInfos[i].playerNo;
         var playerAnimator = SceneController.Instance.playerObjects[PlayerNo].GetComponent <Animator>();
         // トラックを全検索して条件に当てはまるオブジェクトをバインドします
         foreach (var track in director.playableAsset.outputs)
         {
             string trackName = "No" + (i + 1) + "Player";
             if (track.streamName == trackName)
             {
                 director.SetGenericBinding(track.sourceObject, playerAnimator);
                 break;
             }
         }
     }
 }
示例#7
0
 private void ProcessBind(PlayableBinding output, string tag, DynamicDialogueBinder.DialogueBind bind)
 {
     if (output.outputTargetType == typeof(Animator))
     {
         director.SetGenericBinding(output.sourceObject, bind.DialogueBubbleAnimator);
     }
     else if (output.outputTargetType == typeof(GameObject))
     {
         director.SetGenericBinding(output.sourceObject, bind.DialogueBubbleObject);
     }
     else if (output.outputTargetType == typeof(TMPro.TMP_Text))
     {
         director.SetGenericBinding(output.sourceObject, bind.DialogueBubbleText);
     }
     else
     {
         Debug.LogError($"Unsupported binding {output.outputTargetType} : {tag}");
     }
 }
    void Start()
    {
        Player      = PlayerManager.instance.Player.transform.GetChild(0).gameObject;
        PlayerSword = PlayerManager.instance.Player.transform.GetChild(1).gameObject;
        dir         = GetComponent <PlayableDirector>();
        var timeLineAsset = (TimelineAsset)dir.playableAsset;

        foreach (var item in timeLineAsset.outputs)
        {
            if (item.streamName == "PlayerTrack")
            {
                dir.SetGenericBinding(item.sourceObject, Player);
            }
            else if (item.streamName == "WeaponTrack")
            {
                dir.SetGenericBinding(item.sourceObject, PlayerSword);
            }
        }
    }
示例#9
0
    private void SetBindings()
    {
        var timelineAsset    = _timeline.playableAsset;
        var playableBindings = new List <PlayableBinding>(timelineAsset.outputs);

        for (int i = 0; i < TrackReferences.Length; i++)
        {
            var track         = playableBindings[i].sourceObject as TrackAsset;
            var gameObjectRef = GameObject.FindGameObjectWithTag(TrackReferences[i].ToString());
            if (TrackReferences[i] == TimelineTrack.LucyBodyAnimator || TrackReferences[i] == TimelineTrack.LucyFireAnimator || TrackReferences[i] == TimelineTrack.SalamanderAnimator)
            {
                _timeline.SetGenericBinding(track, gameObjectRef.GetComponent <Animator>());
            }
            else
            {
                _timeline.SetGenericBinding(track, gameObjectRef);
            }
        }
    }
示例#10
0
 public void BindAllType <T>(PlayableDirector director, T obj) where T : Object
 {
     foreach (var output in director.playableAsset.outputs)
     {
         if (output.outputTargetType.Equals(typeof(T)))
         {
             director.SetGenericBinding(output.sourceObject, obj as T);
         }
     }
 }
示例#11
0
 void BindPlayerToAnimationTrack()
 {
     foreach (var playableAssetOutput in collectedTimeline.playableAsset.outputs)
     {
         if (playableAssetOutput.streamName == playerAnimationTrackName)
         {
             collectedTimeline.SetGenericBinding(playableAssetOutput.sourceObject, m_player);
         }
     }
 }
示例#12
0
 void BindPlayerToAnimationTrack()
 {
     //Loop through timeline tracks and find the desired track to bind the player to
     foreach (var playableAssetOutput in collectedTimeline.playableAsset.outputs)
     {
         if (playableAssetOutput.streamName == playerAnimationTrackName)
         {
             collectedTimeline.SetGenericBinding(playableAssetOutput.sourceObject, player);
         }
     }
 }
示例#13
0
 private void BindPlayer(Transform playerTransform)
 {
     _objectToBind = GameObject.FindGameObjectWithTag("Player").GetComponent <Animator>();
     foreach (var playableAssetOutput in _playableDirector.playableAsset.outputs)
     {
         if (playableAssetOutput.streamName == trackName)
         {
             _playableDirector.SetGenericBinding(playableAssetOutput.sourceObject, _objectToBind);
         }
     }
 }
示例#14
0
    void Start()
    {
        fdirector             = fabulaTimeline.GetComponent <PlayableDirector>();
        fdirector.initialTime = 0f;

        dc = DiscourseContainer.Load(Path.Combine(Application.dataPath, "Scripts//CinemachineTimelineCode//FileIO_xml//discourse.xml"));

        timeline = (TimelineAsset)ScriptableObject.CreateInstance("TimelineAsset");

        director = GetComponent <PlayableDirector>();

        main_camera_object = GameObject.Find("Main Camera");

        ftrack    = timeline.CreateTrack <CinemachineTrack>(null, "film_track");
        ctrack    = timeline.CreateTrack <ControlTrack>(null, "control_track");
        ntrack    = timeline.CreateTrack <PlayableTrack>(null, "nav_track");
        ptrack    = timeline.CreateTrack <PlayableTrack>(null, "timetravel_track");
        pos_track = timeline.CreateTrack <ControlTrack>(null, "pos_track");

        foreach (DiscourseClip clip in dc.Clips)
        {
            if (clip.Type.Equals("cam_custom"))
            {
                populateCustom(clip);
            }
            else if (clip.Type.Equals("nav_cam"))
            {
                populateNavCam(clip);
            }
            else if (clip.Type.Equals("nav_virtual"))
            {
                populateNavVirtual(clip);
            }
            // cam_timeline cannot time travel
            else if (clip.Type.Equals("cam_timeline"))
            {
                populateCamObject(clip);
            }
            else if (clip.Type.Equals("cntrl_timeline"))
            {
                populateCtrlObject(clip);
                if (clip.fabulaStart >= 0f)
                {
                    addTimeTravel(clip);
                }
            }
            else
            {
                Debug.Log("What TYPE of discourse clip is this?");
            }
        }
        director.SetGenericBinding(ftrack, main_camera_object);
        director.Play(timeline);
    }
    /// <summary>
    /// 组装数据,赋值到timeline中
    /// </summary>
    public void AssemblyTimeline(ScenarioObjController[] actorBinds)
    {
        if (!director)
        {
            return;
        }
        int cnt   = 0;
        var binds = director.playableAsset.outputs.ToArray();

        for (int i = 0; i < binds.Length; i++)
        {
            var bind = binds[i];
            //判断轨道
            if (bind.sourceObject is ActorTrack)
            {
                if (actorBinds[cnt].gameObject)
                {
                    director.SetGenericBinding(bind.sourceObject, actorBinds[cnt].gameObject);
                    //赋值轨道的控制组件
                    //给每个片段赋值,ExposedReference
                }
                cnt++;
            }
            else if (bind.sourceObject is AnimationTrack)
            {
                if (actorBinds.Length <= cnt)
                {
                    Debug.LogError("数据错误");
                }
                else
                {
                    if (actorBinds[cnt].gameObject)
                    {
                        director.SetGenericBinding(bind.sourceObject, actorBinds[cnt].gameObject.GetMissComponent <Animator>());
                    }

                    cnt++;
                }
            }
        }
    }
示例#16
0
    private void Start()
    {
        foreach (var playableAssetOutput in playableDirector.playableAsset.outputs)
        {
            if (playableAssetOutput.streamName == trackName)
            {
                playableDirector.SetGenericBinding(playableAssetOutput.sourceObject, objectToBind);
            }
        }

        playableDirector.Play();
    }
示例#17
0
 private void SetupDirector()
 {
     if (dir != null && !skipCutscene)
     {
         playerGFX   = PlayerManager.instance.Player.transform.GetChild(0).gameObject;
         PlayerSword = PlayerManager.instance.Player.transform.GetChild(1).gameObject;
         var timeLineAsset = (TimelineAsset)dir.playableAsset;
         foreach (var item in timeLineAsset.outputs)
         {
             if (item.streamName == "PlayerTrack")
             {
                 dir.SetGenericBinding(item.sourceObject, playerGFX);
             }
             else if (item.streamName == "WeaponTrack")
             {
                 dir.SetGenericBinding(item.sourceObject, PlayerSword);
             }
         }
         DisablePlayer();
     }
 }
示例#18
0
        public IEnumerator CreatePlayableAsset()
        {
            EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);

            Color            col        = Color.green;
            GameObject       directorGo = new GameObject("Director");
            PlayableDirector director   = directorGo.AddComponent <PlayableDirector>();

            //Create timeline asset
            TimelineAsset asset = ScriptableObject.CreateInstance <TimelineAsset>();

            director.playableAsset = asset;

            //Create empty asset
            FaderPlayableAsset faderAsset = ScriptableObject.CreateInstance <FaderPlayableAsset>();
            FaderTrack         faderTrack = asset.CreateTrack <FaderTrack>(null, "Footage");
            TimelineClip       clip       = faderTrack.CreateDefaultClip();

            clip.asset = faderAsset;
            faderAsset.SetFadeType(FadeType.FADE_IN);
            faderAsset.SetColor(col);

            //Create new Image
            Transform canvasT = UIUtility.CreateCanvas();

            GameObject imageObj = new GameObject("Image");

            imageObj.transform.SetParent(canvasT);
            Image image = imageObj.AddComponent <Image>();

            director.SetGenericBinding(faderTrack, image);

            //Select gameObject and open Timeline Window. This will trigger the TimelineWindow's update etc.
            EditorApplication.ExecuteMenuItem("Window/Sequencing/Timeline");
            Selection.activeTransform = directorGo.transform;
            yield return(null);

            TimelineEditor.selectedClip = clip;
            yield return(null);

            //FadeIn
            Color zeroAlphaCol = col;

            zeroAlphaCol.a = 0;
            Assert.AreEqual(zeroAlphaCol, image.color);

            //FadeOut
            faderAsset.SetFadeType(FadeType.FADE_OUT);
            TimelineEditor.Refresh(RefreshReason.ContentsModified);
            yield return(null); //Give time for the Timeline Window to update.

            Assert.AreEqual(col, image.color);
        }
示例#19
0
        //This should use the binding type for the track instead of just binding a GameObject
        public static void SetGenericBinding(PlayableDirector timelineDirector, TrackAsset trackAsset, GameObject gameObject)
        {
            Type bindingType = trackAsset.outputs.First().sourceBindingType;

            if (bindingType == null || bindingType == typeof(GameObject))
            {
                timelineDirector.SetGenericBinding(trackAsset, gameObject);
            }
            else
            {
                Component c = gameObject.GetComponent(bindingType);
                if (c != null)
                {
                    timelineDirector.SetGenericBinding(trackAsset, c);
                }
                else
                {
                    Debug.LogWarning("Binding type was not found on object " + gameObject);
                }
            }
        }
        /*      public void BindTimelineTracks()
         *    {
         *        Debug.Log("Binding Timeline Tracks!");
         *
         *        timelineAsset = (TimelineAsset)timeline.playableAsset;
         *
         *         // iterate through tracks and map the objects appropriately
         *        for( var i = 0; i < trackList.Count; i ++)
         *        {
         *            if( trackList[i] != null)
         *            {
         *                     var track = (TrackAsset)timelineAsset.outputs;//[i].sourceObject;
         *                                     timeline.SetGenericBinding(track, trackList[i]);
         *            }
         *        }
         *    }
         */
        public void Test()
        {
            int i = 0;

            // This works it puts trackList[0](Gameobject) inn all the spots
            foreach (var output in timeline.playableAsset.outputs)
            {
                i++;
                timeline.SetGenericBinding(output.sourceObject, trackList[i - 1]);
                // goes out of range
            }
        }
示例#21
0
        public static void Bind(PlayableDirector director, TrackAsset bindTo, Object objectToBind)
        {
            if (director == null || bindTo == null || TimelineWindow.instance == null)
            {
                return;
            }

            TimelineWindow.instance.state.previewMode = false; // returns all objects to previous state
            TimelineUndo.PushUndo(director, "PlayableDirector Binding");
            director.SetGenericBinding(bindTo, objectToBind);
            TimelineWindow.instance.state.rebuildGraph = true;
        }
    public void BindTimelineTracks()
    {
        if (brain == null || timeline == null)
        {
            return;
        }
        var timelineAsset = (TimelineAsset)timeline.playableAsset;

        var track = timelineAsset.GetOutputTrack(1);

        timeline.SetGenericBinding(track, brain);
    }
示例#23
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.H))
        {
            foreach (var item in playDir.playableAsset.outputs)
            {
                if (item.streamName == "Attacker Animation")
                {
                    playDir.SetGenericBinding(item.sourceObject, attacker);
                }
                else if (item.streamName == "Victim Animation")
                {
                    playDir.SetGenericBinding(item.sourceObject, victim);
                }
            }

            //playDir.time = 0;
            //playDir.Stop();
            playDir.Play();
            //playDir.Evaluate();
        }
    }
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.H))
        {
            foreach (var track in pd.playableAsset.outputs)
            {
                if (track.streamName.Contains("Attacker"))
                {
                    pd.SetGenericBinding(track.sourceObject, attacker);
                }
                else if (track.streamName.Contains("Victim"))
                {
                    pd.SetGenericBinding(track.sourceObject, victim);
                }
            }

            //pd.Stop();
            //pd.time = 0;
            //pd.Evaluate();//重新计算位置
            pd.Play();
        }
    }
示例#25
0
    public void BindTimelineTracks()
    {
        // Debug.Log("Binding Timeline Tracks!");
        TimelineAsset timelineAsset = (TimelineAsset)director.playableAsset;
        // iterate through tracks and map the objects appropriately

        int i = 0;

        foreach (PlayableBinding binding in timelineAsset.outputs)
        {
            // Debug.Log("Binding[ " + i + " ]: " + binding);
            // Debug.Log("Track: " + binding.sourceObject);
            // Debug.Log("Object: " + director.GetGenericBinding(binding.sourceObject));

            if (director.GetGenericBinding(binding.sourceObject) == null)
            {
                if (i == 1)
                {
                    GameObject trackValue = GameObject.Find("friend_pieces");
                    // Debug.Log("Set Binding to: " + trackValue);
                    director.SetGenericBinding((TrackAsset)binding.sourceObject, trackValue);
                }
                else if (i == 4)
                {
                    GameObject trackValue = GameObject.Find("friend_whole_parent").transform.GetChild(0).gameObject;
                    // Debug.Log("Set Binding to: " + trackValue);
                    director.SetGenericBinding((TrackAsset)binding.sourceObject, trackValue);
                }
                else if (i == 8)
                {
                    GameObject trackValue = GameObject.Find("dorg");
                    // Debug.Log("Set Binding to: " + trackValue);
                    director.SetGenericBinding((TrackAsset)binding.sourceObject, trackValue);
                }
            }

            i++;
        }
    }
示例#26
0
    public void BindToPlayableDirector(PlayableDirector playableDirector)
    {
        foreach (var output in playableDirector.playableAsset.outputs)
        {
            Binding binding = null;
            if (output.sourceObject is CinemachineTrack)
            {
                CinemachineTrack cinemachineTrack = output.sourceObject as CinemachineTrack;
                if (bindingMap.TryGetValue(cinemachineTrack.name, out binding))
                {
                    playableDirector.SetGenericBinding(cinemachineTrack, binding.cinemachineBrain);
                }

                foreach (var clip in cinemachineTrack.GetClips())
                {
                    if (bindingMap.TryGetValue(clip.displayName, out binding))
                    {
                        var cinemachineShot = clip.asset as CinemachineShot;
                        playableDirector.SetReferenceValue(cinemachineShot.VirtualCamera.exposedName, binding.cinemachineVCam);
                    }
                }
            }
            else if (output.sourceObject is AnimationTrack)
            {
                AnimationTrack animationTrack = output.sourceObject as AnimationTrack;
                if (bindingMap.TryGetValue(animationTrack.name, out binding))
                {
                    playableDirector.SetGenericBinding(animationTrack, binding.animator);
                }
            }
            else if (output.sourceObject != null)
            {
                if (bindingMap.TryGetValue(output.sourceObject.name, out binding))
                {
                    playableDirector.SetGenericBinding(output.sourceObject, binding.gameObject);
                }
            }
        }
    }
示例#27
0
    public void Play(EventType eventType, IActorManager player, IActorManager opponent)
    {
        pd.playableAsset = GetTimelineAsset(eventType);
        TimelineAsset timeline = (TimelineAsset)pd.playableAsset;

        foreach (var track in timeline.GetOutputTracks())
        {
            if (track.name == "Player Animation")
            {
                pd.SetGenericBinding(track, player.GetAnimator());
            }
            else if (track.name == "Opponent Animation")
            {
                pd.SetGenericBinding(track, opponent.GetAnimator());
            }
            else if (track.name == "Player Script")
            {
                pd.SetGenericBinding(track, player);
                foreach (var clip in track.GetClips())
                {
                    LockAnimatorClip lockClip = (LockAnimatorClip)clip.asset;
                    lockClip.am.exposedName = System.Guid.NewGuid().ToString();
                    pd.SetReferenceValue(lockClip.am.exposedName, player);
                }
            }
            else if (track.name == "Opponent Script")
            {
                pd.SetGenericBinding(track, opponent);
                foreach (var clip in track.GetClips())
                {
                    LockAnimatorClip lockClip = (LockAnimatorClip)clip.asset;
                    lockClip.am.exposedName = System.Guid.NewGuid().ToString();
                    pd.SetReferenceValue(lockClip.am.exposedName, opponent);
                }
            }
        }
        pd.Evaluate();
        pd.Play();
    }
示例#28
0
        // Use this for initialization
        public bool PopulateTimelines()
        {
            // read clips
            Debug.Log("Reading Clips");

            fabTimelineChild  = GameObject.FindGameObjectWithTag("FabulaTimeline");
            discTimelineChild = GameObject.FindGameObjectWithTag("DiscourseTimeline");

            fab_timeline = (TimelineAsset)ScriptableObject.CreateInstance("TimelineAsset");
            fab_director = fabTimelineChild.GetComponent <PlayableDirector>();

            disc_timeline = (TimelineAsset)ScriptableObject.CreateInstance("TimelineAsset");
            disc_director = discTimelineChild.GetComponent <PlayableDirector>();

            // Load Cinematography Attributes
            ProCamsLensDataTable.Instance.LoadData();
            CinematographyAttributes.lensFovData   = ProCamsLensDataTable.Instance.GetFilmFormat("35mm 16:9 Aperture (1.78:1)").GetLensKitData(0)._fovDataset;
            CinematographyAttributes.standardNoise = Instantiate(Resources.Load("Handheld_tele_mild", typeof(NoiseSettings))) as NoiseSettings;



            // Load Location Graph for pathfinding - only used by Steer typed fabula clips
            if (useGraph)
            {
                TrackAttributes.TG = GameObject.FindGameObjectWithTag("LocationHost").GetComponent <TileGraph>();
                TrackAttributes.TG.InitGraph();
            }
            // Load other Time Track Attribute
            TrackAttributes.TimeTrackManager = new TrackManager(disc_timeline, "timeTravel");

            // Load Film Track Manager
            TrackAttributes.FilmTrackManager = new CinemachineTrackManager(disc_timeline);
            main_camera_object = GameObject.FindGameObjectWithTag("MainCamera");
            disc_director.SetGenericBinding(TrackAttributes.FilmTrackManager.currentTrack, main_camera_object);

            // Load other Other Track Attributes
            TrackAttributes.LerpTrackManager  = new PlayableTrackManager(fab_timeline, "Lerp Track");
            TrackAttributes.steerTrackManager = new SteerTrackManager(fab_timeline, "Steer Track");
            TrackAttributes.discTextTrack     = disc_timeline.CreateTrack <TextSwitcherTrack>(null, "text_track");
            TrackAttributes.fabTextTrack      = fab_timeline.CreateTrack <TextSwitcherTrack>(null, "text_track");
            disc_director.SetGenericBinding(TrackAttributes.discTextTrack, GameObject.Find("DiscourseText").GetComponent <Text>());
            fab_director.SetGenericBinding(TrackAttributes.fabTextTrack, GameObject.Find("FabulaText").GetComponent <Text>());

            // read clips
            ReadFabClipList(fab_clips_as_json.text);
            ReadDiscClipList(disc_clips_as_json.text);

            disc_director.playableAsset = disc_timeline;
            fab_director.playableAsset  = fab_timeline;
            return(true);
        }
        private void Start()
        {
            director.playableAsset = asset;
            var timelineAsset = (TimelineAsset)director.playableAsset;

            for (var i = 0; i < dialogueBoxes.Count; i++)
            {
                var outputs = timelineAsset.outputs.ToArray();
                var track   = (TrackAsset)outputs[i].sourceObject;
                director.SetGenericBinding(track, dialogueBoxes[i]);
            }

            director.Play(asset);
        }
 public void BindTimelineTracks()
 {
     Debug.Log("Binding Timeline Tracks!");
     timelineAsset = (TimelineAsset)timeline.playableAsset;
     // iterate through tracks and map the objects appropriately
     for (var i = 0; i < trackList.Count; i++)
     {
         if (trackList[i] != null)
         {
             var track = (TrackAsset)timelineAsset.GetOutputTrack(i);
             timeline.SetGenericBinding(track, trackList[i]);
         }
     }
 }