Exemplo n.º 1
0
        private void Update()
        {
            // When output received
            if (outputFlag)
            {
                // Parse data
                currentFrame = OPFrame.FromJson(tempOutput);

                // Draw the first person in data
                if (currentFrame.units.Count > 0)
                {
                    human.PushNewUnitData(currentFrame.units[0]);
                    human.SetActive(true);
                }

                // Turn off output flag to receive next data
                outputFlag = false;

                // Calculate framerate
                if (lastFrameTime > 0f)
                {
                    if (avgFrameTime < 0f)
                    {
                        avgFrameTime = Time.time - lastFrameTime;
                    }
                    else
                    {
                        avgFrameTime = Mathf.Lerp(Time.time - lastFrameTime, avgFrameTime, frameRateSmoothRatio);
                        avgFrameRate = 1f / avgFrameTime;
                    }
                }
                lastFrameTime = Time.time;
            }
        }
 private void Update()
 {
     if (outputFlag)
     {
         currentFrame = OPFrame.FromJson(tempOutput);
         if (currentFrame.units.Count > 0)
         {
             human.PushNewUnitData(currentFrame.units[0]);
             human.SetActive(true);
         }
         outputFlag = false;
     }
 }
Exemplo n.º 3
0
        public void PushNewOutput(string json)
        {
            currentFrame = OPFrame.FromJson(json);
            int unitsCount = currentFrame.units.Count;

            for (int i = 0; i < humans.Count; i++)
            {
                if (i < unitsCount)
                {
                    humans[i].PushNewUnitData(currentFrame.units[i]);
                    humans[i].SetActive(true);
                }
                else
                {
                    humans[i].SetActive(false);
                }
            }
        }