public void DeserializeAnimation(AtomAnimation animation, JSONClass animationJSON) { if (animation == null) { throw new ArgumentNullException(nameof(animation)); } animation.speed = DeserializeFloat(animationJSON["Speed"], 1f); animation.master = DeserializeBool(animationJSON["Master"], false); animation.index.StartBulkUpdates(); try { var clipsJSON = animationJSON["Clips"].AsArray; if (clipsJSON == null || clipsJSON.Count == 0) { throw new NullReferenceException("Saved state does not have clips"); } foreach (JSONClass clipJSON in clipsJSON) { var clip = DeserializeClip(clipJSON); animation.AddClip(clip); } } finally { animation.index.EndBulkUpdates(); } }
public void Bind(AtomAnimation animation, IList <IAnimationTargetWithCurves> targets) { Unbind(); _animation = animation; if ((targets?.Count ?? 0) > 0) { _targets = targets; _lines.ClearCurves(); foreach (var target in targets) { target.onAnimationKeyframesModified.AddListener(OnAnimationCurveModified); BindCurves(target); } _lines.SetVerticesDirty(); _noCurves.SetActive(false); _scrubberRect.gameObject.SetActive(true); _time = -1f; } else { _targets = null; _animationLength = 0f; _noCurves.SetActive(true); _scrubberRect.gameObject.SetActive(false); } }
public void Bind(AtomAnimation animation) { this.animation = animation; _controlPanel.Bind(animation); _curveType.Bind(animation); _curves.Bind(animation); }
public void Bind(AtomAnimation animation) { if (_animation != null) { throw new InvalidOperationException("Cannot bind to animation twice"); } _animation = animation; _animation.onTargetsSelectionChanged.AddListener(OnTargetsSelectionChanged); OnTargetsSelectionChanged(); }
public void DeserializeAnimation(AtomAnimation animation, JSONClass animationJSON) { if (animation == null) { throw new ArgumentNullException(nameof(animation)); } animation.speed = DeserializeFloat(animationJSON["Speed"], 1f); JSONArray clipsJSON = animationJSON["Clips"].AsArray; if (clipsJSON == null || clipsJSON.Count == 0) { throw new NullReferenceException("Saved state does not have clips"); } foreach (JSONClass clipJSON in clipsJSON) { var animationName = clipJSON["AnimationName"].Value; var animationLayer = DeserializeString(clipJSON["AnimationLayer"], AtomAnimationClip.DefaultAnimationLayer); var existingClip = animation.GetClip(animationName); if (existingClip != null) { if (existingClip.IsEmpty()) { var clipToRemove = animation.GetClip(animationName); animation.clips.Remove(clipToRemove); clipToRemove.Dispose(); } else { var newAnimationName = GenerateUniqueAnimationName(animation, animationName); SuperController.LogError($"VamTimeline: Imported clip '{animationName}' already exists and will be imported with the name {newAnimationName}"); animationName = newAnimationName; } } var clip = new AtomAnimationClip(animationName, animationLayer) { blendDuration = DeserializeFloat(clipJSON["BlendDuration"], AtomAnimationClip.DefaultBlendDuration), loop = DeserializeBool(clipJSON["Loop"], true), transition = DeserializeBool(clipJSON["Transition"], false), ensureQuaternionContinuity = DeserializeBool(clipJSON["EnsureQuaternionContinuity"], true), nextAnimationName = clipJSON["NextAnimationName"]?.Value, nextAnimationTime = DeserializeFloat(clipJSON["NextAnimationTime"], 0), autoPlay = DeserializeBool(clipJSON["AutoPlay"], false), speed = DeserializeFloat(clipJSON["Speed"], 1), weight = DeserializeFloat(clipJSON["Weight"], 1), }; clip.animationLength = DeserializeFloat(clipJSON["AnimationLength"]).Snap(); DeserializeClip(clip, clipJSON); animation.AddClip(clip); } animation.Initialize(); animation.RebuildAnimationNow(); }
public void Bind(AtomAnimation animation) { UnbindAnimation(); _animation = animation; _animation.TimeChanged.AddListener(OnTimeChanged); _animation.CurrentAnimationChanged.AddListener(OnCurrentAnimationChanged); _animation.AnimationSettingsChanged.AddListener(OnAnimationSettingsChanged); BindClip(_animation.Current); SetScrubberPosition(_animation.Time, true); }
private void UnbindAnimation() { if (_animation == null) { return; } _animation.TimeChanged.RemoveListener(OnTimeChanged); _animation.CurrentAnimationChanged.RemoveListener(OnCurrentAnimationChanged); _animation = null; UnbindClip(); }
public OperationsFactory(AtomAnimation animation, AtomAnimationClip clip) { if (animation == null) { throw new ArgumentNullException(nameof(animation)); } _animation = animation; if (clip == null) { throw new ArgumentNullException(nameof(clip)); } _clip = clip; }
private static string GenerateUniqueAnimationName(AtomAnimation animation, string animationName) { var i = 1; while (true) { var newAnimationName = $"{animationName} ({i})"; if (!animation.clips.Any(c => c.animationName == newAnimationName)) { return(newAnimationName); } i++; } }
private void Unbind() { if (_targets != null) { _lines.ClearCurves(); foreach (var target in _targets) { target.onAnimationKeyframesModified.RemoveListener(OnAnimationCurveModified); } _animation = null; _targets = null; _lines.SetVerticesDirty(); } }
public void Bind(AtomAnimation animation) { _animation = animation; if (_scrubber != null) { _scrubber.animation = animation; } if (_dopeSheet != null) { _dopeSheet.Bind(animation); } _animation.onClipsListChanged.AddListener(OnClipsListChanged); _animation.onCurrentAnimationChanged.AddListener(OnCurrentAnimationChanged); SyncAnimationsListNow(); }
public JSONClass SerializeAnimation(AtomAnimation animation, string animationNameFilter = null) { var animationJSON = new JSONClass { { "Speed", animation.speed.ToString(CultureInfo.InvariantCulture) }, { "Master", animation.master ? "1" : "0" } }; var clipsJSON = new JSONArray(); foreach (var clip in animation.clips.Where(c => animationNameFilter == null || c.animationName == animationNameFilter)) { clipsJSON.Add(SerializeClip(clip)); } animationJSON.Add("Clips", clipsJSON); return(animationJSON); }
private IEnumerator DeferredInit() { yield return(new WaitForEndOfFrame()); if (animation != null) { StartAutoPlay(); yield break; } base.containingAtom.RestoreFromLast(this); if (animation != null) { yield break; } animation = new AtomAnimation(base.containingAtom); animation.Initialize(); BindAnimation(); }
private bool NextExists(AtomAnimationClip clip, string nextName) { if (nextName == AtomAnimation.RandomizeAnimationName) { return(true); } string group; if (AtomAnimation.TryGetRandomizedGroup(nextName, out group)) { return(true); } var next = animation.index.ByLayer(clip.animationLayer).FirstOrDefault(c => c.animationName == nextName); return(next != null); }
public JSONClass SerializeAnimation(AtomAnimation animation, string animationNameFilter = null) { var animationJSON = new JSONClass { { "Speed", animation.speed.ToString(CultureInfo.InvariantCulture) } }; var clipsJSON = new JSONArray(); animationJSON.Add("Clips", clipsJSON); foreach (var clip in animation.clips.Where(c => animationNameFilter == null || c.animationName == animationNameFilter)) { var clipJSON = new JSONClass { { "AnimationName", clip.animationName }, { "AnimationLength", clip.animationLength.ToString(CultureInfo.InvariantCulture) }, { "BlendDuration", clip.blendDuration.ToString(CultureInfo.InvariantCulture) }, { "Loop", clip.loop ? "1" : "0" }, { "Transition", clip.transition ? "1" : "0" }, { "EnsureQuaternionContinuity", clip.ensureQuaternionContinuity ? "1" : "0" }, { "AnimationLayer", clip.animationLayer }, { "Speed", clip.speed.ToString(CultureInfo.InvariantCulture) }, { "Weight", clip.weight.ToString(CultureInfo.InvariantCulture) }, }; if (clip.nextAnimationName != null) { clipJSON["NextAnimationName"] = clip.nextAnimationName; } if (clip.nextAnimationTime != 0) { clipJSON["NextAnimationTime"] = clip.nextAnimationTime.ToString(CultureInfo.InvariantCulture); } if (clip.autoPlay) { clipJSON["AutoPlay"] = "1"; } SerializeClip(clip, clipJSON); clipsJSON.Add(clipJSON); } return(animationJSON); }
public void Bind(AtomAnimation animation) { _controlPanel.Bind(animation); ChangeScreen(GetDefaultScreen()); }
public AtomAnimation DeserializeAnimation(AtomAnimation animation, JSONClass animationJSON, bool overwriteClips = true) { if (animation == null) { animation = new AtomAnimation(_atom) { Speed = DeserializeFloat(animationJSON["Speed"], 1f), InterpolationTimeout = DeserializeFloat(animationJSON["InterpolationTimeout"], 0.25f), InterpolationSpeed = DeserializeFloat(animationJSON["InterpolationSpeed"], 1f), }; } JSONArray clipsJSON = animationJSON["Clips"].AsArray; if (clipsJSON == null || clipsJSON.Count == 0) { throw new NullReferenceException("Saved state does not have clips"); } foreach (JSONClass clipJSON in clipsJSON) { string animationName = clipJSON["AnimationName"].Value; if (animation.Clips.Any(c => c.AnimationName == animationName)) { if (overwriteClips) { SuperController.LogError($"VamTimeline: Imported clip '{animationName}' already exists and will be overwritten"); var clipToRemove = animation.Clips.First(c => c.AnimationName == animationName); animation.Clips.Remove(clipToRemove); clipToRemove.Dispose(); } else { // generate a new name since we don't want to overwrite in this case var i = 1; while (true) { var newAnimationName = $"{animationName} ({i})"; if (!animation.Clips.Any(c => c.AnimationName == newAnimationName)) { SuperController.LogError($"VamTimeline: Imported clip '{animationName}' already exists and will be imported with the name {newAnimationName}"); animationName = newAnimationName; break; } i++; } } } var clip = new AtomAnimationClip(animationName) { BlendDuration = DeserializeFloat(clipJSON["BlendDuration"], AtomAnimationClip.DefaultBlendDuration), loop = DeserializeBool(clipJSON["Loop"], true), Transition = DeserializeBool(clipJSON["Transition"], false), EnsureQuaternionContinuity = DeserializeBool(clipJSON["EnsureQuaternionContinuity"], true), NextAnimationName = clipJSON["NextAnimationName"]?.Value, NextAnimationTime = DeserializeFloat(clipJSON["NextAnimationTime"], 0), AutoPlay = DeserializeBool(clipJSON["AutoPlay"], false) }; clip.animationLength = DeserializeFloat(clipJSON["AnimationLength"]).Snap(); DeserializeClip(clip, clipJSON); animation.AddClip(clip); } animation.Initialize(); animation.RebuildAnimation(); return(animation); }
public TestContext(GameObject gameObject, StringBuilder output, AtomAnimation animation) { this.gameObject = gameObject; this.output = output; this.animation = animation; }
public void Bind(AtomAnimation animation) { _animation = animation; curveTypeJSON.setCallbackFunction = ChangeCurve; OnEnable(); }
public void Bind(AtomAnimation animation) { _animation = animation; _scrubber.animation = animation; _dopeSheet.Bind(animation); }
public AddAnimationOperations(AtomAnimation animation, AtomAnimationClip clip) { _animation = animation; _clip = clip; }
public TargetsOperations(Atom containingAtom, AtomAnimation animation, AtomAnimationClip clip) { _containingAtom = containingAtom; _animation = animation; _clip = clip; }
public TargetsOperation(AtomAnimation animation, AtomAnimationClip clip) { _animation = animation; _clip = clip; }
public ImportOperations(AtomAnimation animation, bool silent = false) { _animation = animation; _silent = silent; }
public LayersOperations(AtomAnimation animation, AtomAnimationClip clip) { _animation = animation; _clip = clip; }
public MocapImportOperations(Atom containingAtom, AtomAnimation animation, AtomAnimationClip clip) { _containingAtom = containingAtom; _animation = animation; this.clip = clip; }
public RecordOperations(AtomAnimation animation, AtomAnimationClip clip) { _animation = animation; _clip = clip; }