public static EditAnimationSet CreateTestSet() { EditAnimationSet set = new EditAnimationSet(); for (int a = 0; a < 5; ++a) { EditAnimation anim = new EditAnimation(); for (int i = 0; i < a + 1; ++i) { var track = new EditTrack(); track.ledIndices = new List <int>(); track.ledIndices.Add(i); for (int j = 0; j < 3; ++j) { var kf = new EditKeyframe(); kf.time = j; kf.color = Random.ColorHSV(); track.keyframes.Add(kf); } anim.tracks.Add(track); } set.animations.Add(anim); } return(set); }
public bool LoadFromJson(DiceType diceType) { string path = GetJsonFilePathname(diceType); bool ret = File.Exists(path); if (ret) { string jsonText = File.ReadAllText(path); animationSet = JsonUtility.FromJson <Animations.EditAnimationSet>(jsonText); animationSet.FixupLedIndices(); timeline.SetAnimations(diceType, animationSet); Debug.Log($"Loaded {diceType} animations from {path}"); } else { animationSet = new Animations.EditAnimationSet(); animationSet.animations = new List <Animations.EditAnimation>(); var anim = new Animations.EditAnimation(); anim.Reset(); animationSet.animations.Add(anim); timeline.SetAnimations(diceType, animationSet); Debug.Log($"Loaded empty {diceType} animation"); } return(ret); }
public void SetAnimations(DiceType diceType, Animations.EditAnimationSet animationSet) { if (animationSet.animations == null) { animationSet.animations = new List <Animations.EditAnimation>(); } if (animationSet.animations.Count == 0) { animationSet.animations.Add(new Animations.EditAnimation()); } // Drop current animation _animIndex = -1; // Store animation set DiceType = diceType; _animationSet = animationSet; RefreshNames(); ShowAnimation(0); }