protected override MetadataHardFilter Create(ReflectBootstrapper hook, ISyncModelProvider provider, IExposedPropertyTable resolver) { var filter = new MetadataHardFilter(output); input.streamBegin = filter.OnBegin; input.streamEvent = filter.OnStreamEvent; input.streamEnd = filter.OnEnd; return(filter); }
public void SetResolver(IExposedPropertyTable value) { PlayableGraph.SetResolver_Injected(ref this, value); }
static bool ExposedReferenceProperty(FieldInfo p_fieldInfo, Object p_object, GUIContent p_name, IReferencable p_reference) { if (!IsExposedReferenceProperty(p_fieldInfo)) { return(false); } IExposedPropertyTable propertyTable = DashEditorCore.EditorConfig.editingController; var exposedReference = p_fieldInfo.GetValue(p_object); PropertyName exposedName = (PropertyName)exposedReference.GetType().GetField("exposedName").GetValue(exposedReference); bool isDefault = PropertyName.IsNullOrEmpty(exposedName); GUILayout.BeginHorizontal(); GUILayout.Label(p_name, GUILayout.Width(160)); HandleReferencing(p_reference, p_fieldInfo); EditorGUI.BeginChangeCheck(); UnityEngine.Object exposedValue = (UnityEngine.Object)exposedReference.GetType().GetMethod("Resolve") .Invoke(exposedReference, new object[] { propertyTable }); var newValue = EditorGUILayout.ObjectField(exposedValue, p_fieldInfo.FieldType.GetGenericArguments()[0], true); GUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { if (propertyTable != null) { Undo.RegisterCompleteObjectUndo(propertyTable as UnityEngine.Object, "Set Exposed Property"); } if (!isDefault) { if (newValue == null) { propertyTable.ClearReferenceValue(exposedName); exposedReference.GetType().GetField("exposedName").SetValue(exposedReference, null); p_fieldInfo.SetValue(p_object, exposedReference); } else { propertyTable.SetReferenceValue(exposedName, newValue); } } else { if (newValue != null) { PropertyName newExposedName = new PropertyName(GUID.Generate().ToString()); exposedReference.GetType().GetField("exposedName") .SetValue(exposedReference, newExposedName); propertyTable.SetReferenceValue(newExposedName, newValue); p_fieldInfo.SetValue(p_object, exposedReference); } } return(true); } return(false); }
public void AddSubSequence(ISequenceState state, IExposedPropertyTable resolver) { subElements.Add(SequencePathSubElement.Create(state, resolver)); }
internal static TrackAsset Duplicate(this TrackAsset track, IExposedPropertyTable sourceTable, IExposedPropertyTable destTable, TimelineAsset destinationTimeline = null) { if (track == null) { return(null); } // if the destination is us, clear to avoid bad parenting (case 919421) if (destinationTimeline == track.timelineAsset) { destinationTimeline = null; } var timelineParent = track.parent as TimelineAsset; var trackParent = track.parent as TrackAsset; if (timelineParent == null && trackParent == null) { Debug.LogWarning("Cannot duplicate track because it is not parented to known type"); return(null); } // Determine who the final parent is. If we are pasting into another track, it's always the timeline. // Otherwise it's the original parent PlayableAsset finalParent = destinationTimeline != null ? destinationTimeline : track.parent; // grab the list of tracks to generate a name from (923360) to get the list of names // no need to do this part recursively var finalTrackParent = finalParent as TrackAsset; var finalTimelineAsset = finalParent as TimelineAsset; var otherTracks = (finalTimelineAsset != null) ? finalTimelineAsset.trackObjects : finalTrackParent.subTracksObjects; // Important to create the new objects before pushing the original undo, or redo breaks the // sequence var newTrack = TimelineHelpers.Clone(finalParent, track, sourceTable, destTable, finalParent); newTrack.name = TimelineCreateUtilities.GenerateUniqueActorName(otherTracks, newTrack.name); RecursiveSubtrackClone(track, newTrack, sourceTable, destTable, finalParent); TimelineCreateUtilities.SaveAssetIntoObject(newTrack, finalParent); TimelineUndo.RegisterCreatedObjectUndo(newTrack, "Duplicate"); TimelineUndo.PushUndo(finalParent, "Duplicate"); if (destinationTimeline != null) // other timeline { destinationTimeline.AddTrackInternal(newTrack); } else if (timelineParent != null) // this timeline, no parent { ReparentTracks(new List <TrackAsset> { newTrack }, timelineParent, timelineParent.GetRootTracks().Last(), false); } else // this timeline, with parent { trackParent.AddChild(newTrack); } // Call the custom editor. this check prevents the call when copying to the clipboard if (destinationTimeline == null || destinationTimeline == TimelineEditor.inspectedAsset) { var customEditor = CustomTimelineEditorCache.GetTrackEditor(newTrack); try { customEditor.OnCreate(newTrack, track); } catch (Exception e) { Debug.LogException(e); } } return(newTrack); }
protected override StreamIndicator Create(ReflectBootstrapper hook, ISyncModelProvider provider, IExposedPropertyTable resolver) { var node = new StreamIndicator(settings); streamAssetInput.streamBegin = node.OnAssetStreamBegin; streamAssetInput.streamEvent = node.OnAssetStreamEvent; streamAssetInput.streamEnd = node.OnAssetStreamEnd; streamInstanceInput.streamBegin = node.OnInstanceStreamBegin; streamInstanceInput.streamEvent = node.OnInstanceStreamEvent; streamInstanceInput.streamEnd = node.OnInstanceStreamEnd; streamInstanceDataInput.streamBegin = node.OnInstanceDataStreamBegin; streamInstanceDataInput.streamEnd = node.OnInstanceDataStreamEnd; gameObjectInput.streamBegin = node.OnGameObjectStreamBegin; gameObjectInput.streamEvent = node.OnGameObjectStreamEvent; gameObjectInput.streamEnd = node.OnGameObjectStreamEnd; return(node); }
protected override MetadataFilter Create(ReflectBootstrapper hook, ISyncModelProvider provider, IExposedPropertyTable resolver) { var p = new MetadataFilter(settings); instanceInput.streamEvent = p.OnStreamInstanceEvent; instanceInput.streamEnd = p.OnStreamInstanceEnd; gameObjectInput.streamEvent = p.OnGameObjectAdded; gameObjectInput.streamEnd = p.OnGameObjectEnd; return(p); }
// Creates a complete clone of a track and returns it. // Does not parent, or add the track to the sequence public static TrackAsset Clone(PlayableAsset parent, TrackAsset trackAsset, IExposedPropertyTable sourceTable, IExposedPropertyTable destTable, PlayableAsset assetOwner = null) { if (trackAsset == null) { return(null); } var timelineAsset = trackAsset.timelineAsset; if (timelineAsset == null) { return(null); } if (assetOwner == null) { assetOwner = parent; } // create a duplicate, then clear the clips and subtracks var newTrack = Object.Instantiate(trackAsset); newTrack.name = trackAsset.name; newTrack.ClearClipsInternal(); newTrack.parent = parent; newTrack.ClearSubTracksInternal(); if (trackAsset.hasCurves) { newTrack.curves = CloneAnimationClip(trackAsset.curves, assetOwner); } var animTrack = trackAsset as AnimationTrack; if (animTrack != null && animTrack.infiniteClip != null) { ((AnimationTrack)newTrack).infiniteClip = CloneAnimationClip(animTrack.infiniteClip, assetOwner); } foreach (var clip in trackAsset.clips) { var newClip = DuplicateClip(clip, sourceTable, destTable, assetOwner); newClip.parentTrack = newTrack; } newTrack.ClearMarkers(); foreach (var e in trackAsset.GetMarkersRaw()) { var newMarker = Object.Instantiate(e); newTrack.AddMarker(newMarker); SaveCloneToAsset(newMarker, assetOwner); if (newMarker is IMarker) { (newMarker as IMarker).Initialize(newTrack); } } newTrack.SetCollapsed(trackAsset.GetCollapsed()); // calling code is responsible for adding to asset, adding to sequence, and parenting, // and duplicating subtracks return(newTrack); }
public static IEnumerable <ITimelineItem> DuplicateItemsUsingCurrentEditMode(IExposedPropertyTable sourceTable, IExposedPropertyTable destTable, ItemsPerTrack items, TrackAsset targetParent, double candidateTime, string undoOperation) { if (targetParent != null) { var aTrack = targetParent as AnimationTrack; if (aTrack != null) { aTrack.ConvertToClipMode(); } var duplicatedItems = DuplicateItems(items, targetParent, sourceTable, destTable, undoOperation); FinalizeInsertItemsUsingCurrentEditMode(new[] { duplicatedItems }, candidateTime); return(duplicatedItems.items); } return(Enumerable.Empty <ITimelineItem>()); }
protected override SyncObjectInstanceProvider Create(ReflectBootstrapper hook, ISyncModelProvider provider, IExposedPropertyTable resolver) { var node = new SyncObjectInstanceProvider(hook.services.eventHub, provider, output); input.streamBegin = node.OnStreamInstanceBegin; input.streamEvent = node.OnStreamInstanceEvent; input.streamEnd = node.OnStreamInstanceEnd; node.Run(); return(node); }
public static TimelineClip Clone(TimelineClip clip, IExposedPropertyTable sourceTable, IExposedPropertyTable destTable, double time, PlayableAsset newOwner = null) { if (newOwner == null) { newOwner = clip.parentTrack; } TimelineClip newClip = DuplicateClip(clip, sourceTable, destTable, newOwner); newClip.start = time; var track = newClip.parentTrack; track.SortClips(); TrackExtensions.ComputeBlendsFromOverlaps(track.clips); return(newClip); }
protected override URPMaterialConverter Create(ReflectBootstrapper hook, ISyncModelProvider provider, IExposedPropertyTable resolver) { var p = new URPMaterialConverter(hook.services.eventHub, hook.services.memoryTracker, textureCacheParam.value, output, m_ReflectUniversalRp); input.streamEvent = p.OnStreamEvent; return(p); }
protected abstract void PopulateContextMenu(GenericMenu menu, OverrideState overrideState, IExposedPropertyTable exposedPropertyTable, SerializedProperty exposedName, SerializedProperty defaultValue);
protected abstract void OnRenderProperty(Rect position, PropertyName exposedPropertyNameString, Object currentReferenceValue, SerializedProperty exposedPropertyDefault, SerializedProperty exposedPropertyName, ExposedPropertyMode mode, IExposedPropertyTable exposedProperties);
protected override void PrepareReferences(OutOfScreenTranslationBehaviour clone, IExposedPropertyTable resolver) { base.PrepareReferences(clone, resolver); clone.m_AnimationType = m_AnimationType; }
public static IEnumerable <ITimelineItem> DuplicateItemsUsingCurrentEditMode(IExposedPropertyTable sourceTable, IExposedPropertyTable destTable, IEnumerable <ItemsPerTrack> items, double candidateTime, string undoOperation) { var duplicatedItemsGroups = new List <ItemsPerTrack>(); foreach (var i in items) { duplicatedItemsGroups.Add(DuplicateItems(i, i.targetTrack, sourceTable, destTable, undoOperation)); } FinalizeInsertItemsUsingCurrentEditMode(duplicatedItemsGroups, candidateTime); return(duplicatedItemsGroups.SelectMany(i => i.items)); }
protected override SpatialFilter Create(ReflectBootstrapper hook, ISyncModelProvider provider, IExposedPropertyTable resolver) { var p = new SpatialFilter(hook.helpers.clock, hook.helpers.memoryStats, hook.services.eventHub, hook.systems.memoryCleaner.memoryLevel, settings, assetOutput, visibilityOutput, resolver); assetInput.streamBegin = assetOutput.SendBegin; assetInput.streamEvent = p.OnStreamAssetEvent; assetInput.streamEnd = p.OnStreamInstanceEnd; gameObjectInput.streamEvent = p.OnStreamGameObjectEvent; return p; }
internal static ItemsPerTrack DuplicateItems(ItemsPerTrack items, TrackAsset target, IExposedPropertyTable sourceTable, IExposedPropertyTable destTable, string undoOperation) { var duplicatedItems = new List <ITimelineItem>(); var clips = items.clips.ToList(); if (clips.Any()) { TimelineUndo.PushUndo(target, undoOperation); duplicatedItems.AddRange(DuplicateClips(clips, sourceTable, destTable, target).ToItems()); TimelineUndo.PushUndo(target, undoOperation); // second undo causes reference fixups on redo (case 1063868) } var markers = items.markers.ToList(); if (markers.Any()) { duplicatedItems.AddRange(MarkerModifier.CloneMarkersToParent(markers, target).ToItems()); } return(new ItemsPerTrack(target, duplicatedItems.ToArray())); }
protected override MetadataFilter Create(ReflectBootstrapper hook, ISyncModelProvider provider, IExposedPropertyTable resolver) { var node = new MetadataFilter(settings, outputTrue, outputFalse); input.streamEvent = node.OnStreamInstanceEvent; return(node); }
internal static TimelineClip Clone(TimelineClip clip, IExposedPropertyTable sourceTable, IExposedPropertyTable destTable, PlayableAsset newOwner) { var editorClip = EditorClipFactory.GetEditorClip(clip); // Workaround for Clips not being unity object, assign it to a editor clip wrapper, clone it, and pull the clip back out var newClip = Object.Instantiate(editorClip).clip; // perform fix ups for what Instantiate cannot properly detect SelectionManager.Remove(newClip); newClip.parentTrack = null; newClip.curves = null; // instantiate might copy the reference, we need to clear it // curves are explicitly owned by the clip if (clip.curves != null) { newClip.CreateCurves(AnimationTrackRecorder.GetUniqueRecordedClipName(newOwner, clip.curves.name)); EditorUtility.CopySerialized(clip.curves, newClip.curves); TimelineCreateUtilities.SaveAssetIntoObject(newClip.curves, newOwner); } ScriptableObject playableAsset = newClip.asset as ScriptableObject; if (playableAsset != null && newClip.asset is IPlayableAsset) { var clone = CloneReferencedPlayableAsset(playableAsset, sourceTable, destTable, newOwner); newClip.asset = clone; // special case to make the name match the recordable clips, but only if they match on the original clip var originalRecordedAsset = clip.asset as AnimationPlayableAsset; if (clip.recordable && originalRecordedAsset != null && originalRecordedAsset.clip != null) { AnimationPlayableAsset clonedAnimationAsset = clone as AnimationPlayableAsset; if (clonedAnimationAsset != null && clonedAnimationAsset.clip != null) { clonedAnimationAsset.clip = CloneAnimationClip(originalRecordedAsset.clip, newOwner); if (clip.displayName == originalRecordedAsset.clip.name && newClip.recordable) { clonedAnimationAsset.name = clonedAnimationAsset.clip.name; newClip.displayName = clonedAnimationAsset.name; } } } } return(newClip); }
extern public void SetResolver(IExposedPropertyTable value);
static TimelineClip[] DuplicateClips(IEnumerable <TimelineClip> clips, IExposedPropertyTable sourceTable, IExposedPropertyTable destTable, PlayableAsset newOwner) { var newClips = new TimelineClip[clips.Count()]; int i = 0; foreach (var clip in clips) { var newParent = newOwner == null ? clip.parentTrack : newOwner; var newClip = DuplicateClip(clip, sourceTable, destTable, newParent); newClip.parentTrack = null; newClips[i++] = newClip; } return(newClips); }
internal static void RecursiveSubtrackClone(TrackAsset source, TrackAsset duplicate, IExposedPropertyTable sourceTable, IExposedPropertyTable destTable, PlayableAsset assetOwner) { var subtracks = source.GetChildTracks(); foreach (var sub in subtracks) { var newSub = TimelineHelpers.Clone(duplicate, sub, sourceTable, destTable, assetOwner); duplicate.AddChild(newSub); RecursiveSubtrackClone(sub, newSub, sourceTable, destTable, assetOwner); // Call the custom editor on Create var customEditor = CustomTimelineEditorCache.GetTrackEditor(newSub); try { customEditor.OnCreate(newSub, sub); } catch (Exception e) { Debug.LogException(e); } // registration has to happen AFTER recursion TimelineCreateUtilities.SaveAssetIntoObject(newSub, assetOwner); TimelineUndo.RegisterCreatedObjectUndo(newSub, "Duplicate"); } }
public static void CloneExposedReferences(ScriptableObject clone, IExposedPropertyTable sourceTable, IExposedPropertyTable destTable) { var cloneObject = new SerializedObject(clone); SerializedProperty prop = cloneObject.GetIterator(); while (prop.Next(true)) { if (prop.propertyType == SerializedPropertyType.ExposedReference) { var exposedNameProp = prop.FindPropertyRelative("exposedName"); var sourceKey = exposedNameProp.stringValue; var destKey = sourceKey; if (!IsExposedReferenceExplicitlyNamed(sourceKey)) { destKey = GenerateExposedReferenceName(); } exposedNameProp.stringValue = destKey; var requiresCopy = sourceTable != destTable || sourceKey != destKey; if (requiresCopy && sourceTable != null && destTable != null) { var valid = false; var target = sourceTable.GetReferenceValue(sourceKey, out valid); if (valid && target != null) { var existing = destTable.GetReferenceValue(destKey, out valid); if (!valid || existing != target) { var destTableObj = destTable as UnityEngine.Object; if (destTableObj != null) { TimelineUndo.PushUndo(destTableObj, "Create Clip"); } destTable.SetReferenceValue(destKey, target); } } } } } cloneObject.ApplyModifiedPropertiesWithoutUndo(); }
protected override BoundingBoxController Create(ReflectBootstrapper hook, ISyncModelProvider provider, IExposedPropertyTable resolver) { var p = new BoundingBoxController(hook.services.eventHub, settings.boundingBoxRoot.Resolve(resolver), settings); assetInput.streamEvent = p.OnAssetEvent; filteredInput.streamEvent = p.OnFilteredAssetEvent; instanceInput.streamEvent = p.OnInstanceEvent; instanceDataInput.streamEvent = p.OnInstanceDataEvent; gameObjectInput.streamEvent = p.OnGameObjectEvent; visibilityInput.streamEvent = p.OnVisibilityEvent; assetInput.streamEnd = p.OnAssetEnd; return(p); }
static TimelineClip DuplicateClip(TimelineClip clip, IExposedPropertyTable sourceTable, IExposedPropertyTable destTable, PlayableAsset newOwner) { var newClip = Clone(clip, sourceTable, destTable, newOwner); var track = clip.parentTrack; if (track != null) { newClip.parentTrack = track; track.AddClip(newClip); } var editor = CustomTimelineEditorCache.GetClipEditor(clip); try { editor.OnCreate(newClip, track, clip); } catch (Exception e) { Debug.LogException(e); } return(newClip); }
private static extern void SetResolver_Injected(ref PlayableGraph _unity_self, IExposedPropertyTable value);
public static ScriptableObject CloneReferencedPlayableAsset(ScriptableObject original, IExposedPropertyTable sourceTable, IExposedPropertyTable destTable, Object newOwner) { var clone = Object.Instantiate(original); SaveCloneToAsset(clone, newOwner); if (clone == null || (clone as IPlayableAsset) == null) { throw new InvalidCastException("could not cast instantiated object into IPlayableAsset"); } CloneExposedReferences(clone, sourceTable, destTable); TimelineUndo.RegisterCreatedObjectUndo(clone, "Create clip"); return(clone); }
protected override MaterialConverter Create(ReflectBootstrapper hook, ISyncModelProvider provider, IExposedPropertyTable resolver) { var converter = new SampleMaterialConverter(hook.services.eventHub, hook.services.memoryTracker, textureCacheParam.value, output, opaqueShader, transparentShader); input.streamEvent = converter.OnStreamEvent; return(converter); }
protected override void PopulateContextMenu(GenericMenu menu, OverrideState overrideState, IExposedPropertyTable exposedPropertyTable, SerializedProperty exposedName, SerializedProperty defaultValue) { var propertyName = new PropertyName(exposedName.stringValue); OverrideState currentOverrideState; UnityEngine.Object currentValue = Resolve(new PropertyName(exposedName.stringValue), exposedPropertyTable, defaultValue.objectReferenceValue, out currentOverrideState); if (overrideState == OverrideState.DefaultValue) { menu.AddItem(new GUIContent(ExposePropertyContent.text), false, (userData) => { var guid = UnityEditor.GUID.Generate(); exposedName.stringValue = guid.ToString(); exposedName.serializedObject.ApplyModifiedProperties(); var newPropertyName = new PropertyName(exposedName.stringValue); Undo.RecordObject(exposedPropertyTable as Object, "Set Exposed Property"); exposedPropertyTable.SetReferenceValue(newPropertyName, currentValue); }, null); } else { menu.AddItem(UnexposePropertyContent, false, (userData) => { exposedName.stringValue = ""; exposedName.serializedObject.ApplyModifiedProperties(); Undo.RecordObject(exposedPropertyTable as Object, "Clear Exposed Property"); exposedPropertyTable.ClearReferenceValue(propertyName); }, null); } }