Esempio n. 1
0
        private void UpdatePlayableBindingsIfRequired(PlayableAsset playableAsset, PlayableDirector director)
        {
            m_SynchedPlayableBindings = new PlayableBinding[0];

            if (playableAsset != null)
            {
                var bindings = playableAsset.outputs;
                m_SynchedPlayableBindings = bindings.ToArray();
            }

            foreach (var binding in m_SynchedPlayableBindings)
            {
                // don't add bindings without a specific target type, clear previously bound objects
                // This can happen with timeline tracks that do not have a specific binding.
                if (binding.outputTargetType == null)
                {
                    director.ClearGenericBinding(binding.sourceObject);
                }
                else if (!director.HasGenericBinding(binding.sourceObject))
                {
                    director.SetGenericBinding(binding.sourceObject, null);
                }
            }

            serializedObject.Update();
        }
Esempio n. 2
0
 private void SynchSceneBindings()
 {
     if (base.targets.Length <= 1)
     {
         PlayableDirector playableDirector = (PlayableDirector)base.target;
         PlayableAsset    playableAsset    = this.m_PlayableAsset.objectReferenceValue as PlayableAsset;
         this.m_BindingPropertiesCache.Clear();
         this.m_SynchedPlayableBindings = null;
         if (!(playableAsset == null))
         {
             IEnumerable <PlayableBinding> outputs = playableAsset.outputs;
             this.m_SynchedPlayableBindings = outputs.ToArray <PlayableBinding>();
             PlayableBinding[] synchedPlayableBindings = this.m_SynchedPlayableBindings;
             for (int i = 0; i < synchedPlayableBindings.Length; i++)
             {
                 PlayableBinding playableBinding = synchedPlayableBindings[i];
                 if (!playableDirector.HasGenericBinding(playableBinding.sourceObject))
                 {
                     playableDirector.SetGenericBinding(playableBinding.sourceObject, null);
                 }
             }
             base.serializedObject.Update();
             SerializedProperty[] array = new SerializedProperty[this.m_SceneBindings.arraySize];
             for (int j = 0; j < this.m_SceneBindings.arraySize; j++)
             {
                 array[j] = this.m_SceneBindings.GetArrayElementAtIndex(j);
             }
             PlayableBinding[] synchedPlayableBindings2 = this.m_SynchedPlayableBindings;
             for (int k = 0; k < synchedPlayableBindings2.Length; k++)
             {
                 PlayableBinding      binding = synchedPlayableBindings2[k];
                 SerializedProperty[] array2  = array;
                 for (int l = 0; l < array2.Length; l++)
                 {
                     SerializedProperty serializedProperty = array2[l];
                     if (serializedProperty.FindPropertyRelative("key").objectReferenceValue == binding.sourceObject)
                     {
                         this.m_BindingPropertiesCache.Add(new DirectorEditor.BindingPropertyPair
                         {
                             binding  = binding,
                             property = serializedProperty.FindPropertyRelative("value")
                         });
                         break;
                     }
                 }
             }
         }
     }
 }