0

My Json file looks something like this (it's huge, so this is just simplified):

{
"foo": {
"id": [
  20,
  1,
  3,
  4,
  60,
  1,
],
"times": [
  330.89,
  5.33,
  353.89,
  33.89,
  14.5,
  207.5,
]
},
"poo": {
"id": [
  20,
  1,
  3,
  4,
  60,
  1,
],
"times": [
  3.5,
  323.89,
  97.7,
  154.5,
  27.5,
  265.60,
]
}
}

I have a similar json file as the one above, but a much more complex one. What I want to do is to use the "time" and "id" data and perform an action for the right "id" at the exact time. So the variables id and times are actually mapped to each other (has the same index). Is there a method to take out the right id for the right time to perform an action without having too many complicated loops?

  • This may be rather broad, since it is three questions. Would you trim it down to one? In your first question, are you asking if the JSON is valid, or if it is valid for Unity purposes? In the first case, the answer is yes - you can check this yourself [using a JSON viewer](http://jsonviewer.stack.hu/). – halfer Sep 19 '17 at 08:12
  • "The third question, how can I animate something based on time, what kind of loop should I use?" What do you wish to animate? For most things you can use Unity's Animator and Animation system, there are various guides on using them. – Doh09 Sep 19 '17 at 12:21
  • So, I changed the formulation of my question, is this better? – Vincent Erik Wong Sep 19 '17 at 20:50

0 Answers0