private void SetAnimationClip(RuntimeAnimationClip clip, GameObject go) { RuntimeAnimation animation = go.GetComponent <RuntimeAnimation>(); animation.Clips = new List <RuntimeAnimationClip> { clip }; animation.ClipIndex = 0; UpdateTargetAnimation(); m_propertiesView.Target = animation; m_timelineView.Target = animation; CurrentClip = clip; ExposeToEditor exposeToEditor = go.GetComponent <ExposeToEditor>(); if (exposeToEditor != null && animation != null) { exposeToEditor.ReloadComponentEditor(animation, true); } animation.Refresh(); UpdateCreateViewState(); }
public void ResolveComponents(RuntimeAnimationClip clip, RuntimeAnimation animation) { foreach (RuntimeAnimationProperty property in clip.Properties) { _ResolveComponents(property, animation); } }
private void UpdateTargetAnimation() { if (Editor.Selection.activeGameObject != null) { RuntimeAnimation animation = Editor.Selection.activeGameObject.GetComponent <RuntimeAnimation>(); Target = animation; } else { Target = null; } }
protected override void UpdateOverride() { base.UpdateOverride(); UnityObject activeTool = Editor.Tools.ActiveTool; if (activeTool is BaseHandle) { if (!m_isEditing) { BeginEdit(); } m_isEditing = true; } else { if (m_isEditing) { EndEdit(); } m_isEditing = false; } bool isInPreviewMode = m_target != null && m_target.IsInPreviewMode; if (m_previewToggle.isOn != isInPreviewMode) { m_previewToggle.isOn = isInPreviewMode; } bool isPlaying = m_target != null && m_target.IsPlaying; if (m_playToggle.isOn != isPlaying) { m_playToggle.isOn = isPlaying; } if (m_currentSample != m_timelineView.CurrentSample) { m_currentSample = m_timelineView.CurrentSample; m_frameInput.text = m_currentSample.ToString(); } object t = Target; if (t != null && Target == null) { Target = null; UpdateCreateViewState(); } }
private void UpdateTargetAnimation() { if (TargetGameObject != null) { RuntimeAnimation animation = TargetGameObject.GetComponent <RuntimeAnimation>(); Target = animation; } else { Target = null; } }
private void OnSaveCompleted(ISaveAssetDialog sender, UnityObject asset) { sender.SaveCompleted -= OnSaveCompleted; if (asset == null) { return; } RuntimeAnimationClip clip = (RuntimeAnimationClip)asset; GameObject go = TargetGameObject; ExposeToEditor exposeToEditor = go.GetComponent <ExposeToEditor>(); if (exposeToEditor != null) { Editor.Undo.BeginRecord(); if (!exposeToEditor.GetComponent <RuntimeAnimation>()) { Editor.Undo.AddComponent(exposeToEditor, typeof(RuntimeAnimation)); } Editor.Undo.CreateRecord(redoRecord => { SetAnimationClip(clip, go); return(true); }, undoRecord => { RuntimeAnimation animation = exposeToEditor.GetComponent <RuntimeAnimation>(); if (animation != null) { animation.Clips = null; } UpdateTargetAnimation(); m_propertiesView.Target = null; m_timelineView.Target = null; UpdateCreateViewState(); return(true); }); Editor.Undo.EndRecord(); } else { if (!go.GetComponent <RuntimeAnimation>()) { go.AddComponent <RuntimeAnimation>(); } } SetAnimationClip(clip, go); }
private void _ResolveComponents(RuntimeAnimationProperty property, RuntimeAnimation animation) { if (property.HasChildren) { if (property.ComponentIsNull) { ResolveComponent(property, animation); } foreach (RuntimeAnimationProperty child in property.Children) { _ResolveComponents(child, animation); } } else { if (property.ComponentIsNull) { ResolveComponent(property, animation); } } }
private void ResolveComponent(RuntimeAnimationProperty property, RuntimeAnimation target) { Type componentType = property.ComponentType; if (componentType == null) { return; } m_voidComponentEditor.Components = new[] { target.GetComponent(componentType) }; PropertyDescriptor[] propertyDescriptors = m_editorsMap.GetPropertyDescriptors(componentType, m_voidComponentEditor); for (int i = 0; i < propertyDescriptors.Length; ++i) { PropertyDescriptor desc = propertyDescriptors[i]; if (property.PropertyName == desc.MemberInfo.Name) { property.Component = desc.Target; break; } } }