• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by mdlp · Nov 16, 2018 at 07:20 PM · scripting problemreferencetimelinecliptrack

Peculiar Bleed-through of Exposed References on different Timeline Tracks

I am experiencing some confusion regarding exposed references. I am assigning the track binding to a particular type of clip that will output at runtime to limb targets (my target class is named LimbController) for FinalK scripts. During editing, the clips need to know what LimbController they are affecting (only one target per track, so all the clips on a particular track will affect a single target, although there may be multiple tracks for different LimbControllers), so I have the Track set the exposed reference for each clip in the CreateTrackMixer method.

This seems to work just fine, with one exception--any clip on any track with an unassigned exposed reference will get a LimbController assigned to it if any LimbControlTrack has set a LimbControllers as it's binding. This includes exposed references for other LimbControlClips but also includes completely unrelated and incompatible classes like CinemachineShots. (see image, below) . ## -- ## Once an appropriate Exposed Reference has been assigned for a clip (or in the case of a different LimbControlTrack , for the entire track), the Exposed References seem to be stable and do not get over-written later. I seem to be unintentionally setting a LimbController reference as the default reference for any clip on any track that doesn't have one already assigned to it via other means. The incorrect references can be corrected, and, once changed don't revert, so this doesn't seem (yet) to be a big deal, but I am concerned that there might be more to this than just pointless and temporary defaulting to an incorrect reference.

 using UnityEngine;
 using UnityEngine.Playables;
 using UnityEngine.Timeline;
 using System.Collections.Generic;
 
 [TrackColor(1f, 0.384f, 0f)]
 [TrackClipType(typeof(LimbControlClip))]
 [TrackBindingType(typeof(LimbController))]
 public class LimbControlTrack : TrackAsset
 {
     public LimbController _mTrackBinding;
 
     public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
     {
         //check if track binding has been set 
         if (_mTrackBinding != null)
         {
             //iterator for all currently existing clips on this track
             IEnumerable<TimelineClip> clips = GetClips();
             PlayableDirector director = go.GetComponent<PlayableDirector>();
             //check each Timeline clip
             foreach (var item in clips)
             {
                 // get LimbControlClip encapulated in TimelineClip container
                 LimbControlClip limbControlClip = item.asset as LimbControlClip;
                 // change ExposedName to name of trackbinding object to avoid
                 // name collision when multiple LimbControlTracks in same Timeline
                 limbControlClip.limbController.exposedName = _mTrackBinding.name;
                 // assign exposedReference for clip
                 director.SetReferenceValue(limbControlClip.limbController.exposedName, _mTrackBinding);
             }
         }
         return ScriptPlayable<LimbControlMixerBehaviour>.Create(graph, inputCount);
     }
 
     public override void GatherProperties(PlayableDirector director, IPropertyCollector driver)
     {
         LimbController trackBinding = director.GetGenericBinding(this) as LimbController;
         if (trackBinding == null)
             return;
         _mTrackBinding = trackBinding;
         base.GatherProperties(director, driver);
     }
 }
 
    
        




cinemachineshot.jpg (21.9 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by seant_unity · Nov 16, 2018 at 07:39 PM

You shouldn't need to use an exposed reference per clip to get the track binding. The track binding is passed in the playerData parameter of PlayableBehaviour.ProcessFrame(). You just need to cast it to the binding type - in your case a LimbController.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by mdlp · Nov 16, 2018 at 08:16 PM

This is purely needed during the editing process. When a particular LimbControlClip has been selected, it needs to be able to read data from the LimbController and store it in the clip's behavour. During playback, you are correct, the exposed reference is not needed, but processframe doesn't have access to the permanent LimbControlBehaviour, only a temporary clone.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image seant_unity · Nov 17, 2018 at 12:18 PM 0
Share

Ok, I'd suggest skipping the exposed reference and just set a property (or non-serialized field) on the LimbControlBehaviour, or the LimbControlClip, for the LimbController.

avatar image mdlp seant_unity · Nov 27, 2018 at 04:41 PM 0
Share

Thanks, I will give it a try. I know that non-embedded references won't get stored in the clip asset, but the track seems run CreateTrack$$anonymous$$ixer every tick that the track is active, whether I want it to or not, so I could reassign it every edit session, if necessary.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

171 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to get the Track and the Clip of a Timeline? 1 Answer

How to reference a TrackAsset or PlayableAsset 2 Answers

How can I change a float value of an instantiated object from another script? 3 Answers

Issues with Playable Director rotation offset 1 Answer

Referencing Mono Framework assemblies 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges