Search Unity

Animator is not changing any value in structure. And very low fps on windows phone.

Discussion in 'Windows' started by medvedya2012, Dec 14, 2014.

  1. medvedya2012

    medvedya2012

    Joined:
    May 27, 2014
    Posts:
    41
    I created the animation and added to Animator controller. This animation modify properties in Serializable structure. That works on PC x86 application, but on Windows store application(arm and metro) doesn't work.
    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. public class TestAnimator : MonoBehaviour {
    5.  
    6.     [System.Serializable]
    7.     public struct AnimationProp
    8.     {
    9.         public float x_position;
    10.     }
    11.     public Transform obj;
    12.     public AnimationProp animationProp;
    13.     void Update () {
    14.         Vector3 currentObjPos = obj.transform.position;
    15.         currentObjPos.x = animationProp.x_position;
    16.         obj.transform.position = currentObjPos;
    17.     }
    18. }
    19.  
    I builded my game for windows phone 8.1 and run it on Nokia lumia 930. And I got very low fps. I builded the application with only one script for showing fps and one UI text with canvas. any way I was getting very low fps about 30-40 fps.
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. namespace Medvedya.DebugUtilletes
    4. {
    5.     [RequireComponent(typeof(UnityEngine.UI.Text))]
    6.     public class DrawFPS : MonoBehaviour
    7.     {
    8.  
    9.         // Attach this to a GUIText to make a frames/second indicator.
    10.         //
    11.         // It calculates frames/second over each updateInterval,
    12.         // so the display does not keep changing wildly.
    13.         //
    14.         // It is also fairly accurate at very low FPS counts (<10).
    15.         // We do this not by simply counting frames per interval, but
    16.         // by accumulating FPS for each frame. This way we end up with
    17.         // correct overall FPS even if the interval renders something like
    18.         // 5.5 frames.
    19.  
    20.         public float updateInterval = 0.5F;
    21.  
    22.         private float accum = 0; // FPS accumulated over the interval
    23.         private int frames = 0; // Frames drawn over the interval
    24.         private float timeleft; // Left time for current interval
    25.  
    26.         public UnityEngine.UI.Text text;
    27.         void Start()
    28.         {
    29.             text = GetComponent<UnityEngine.UI.Text>();
    30.             timeleft = updateInterval;
    31.  
    32.         }
    33.  
    34.         void Update()
    35.         {
    36.             timeleft -= Time.deltaTime;
    37.             accum += Time.timeScale / Time.deltaTime;
    38.             ++frames;
    39.  
    40.             // Interval ended - update GUI text and start new interval
    41.             if (timeleft <= 0.0)
    42.             {
    43.                 // display two fractional digits (f2 format)
    44.                 float fps = accum / frames;
    45.                 string format = System.String.Format("{0:F2} FPS", fps);
    46.                 text.text = format;
    47.  
    48.                 if (fps < 30)
    49.                     text.color = Color.yellow;
    50.                 else
    51.                     if (fps < 10)
    52.                         text.color = Color.red;
    53.                     else
    54.                         text.color = Color.green;
    55.                 //    DebugConsole.Log(format,level);
    56.                 timeleft = updateInterval;
    57.                 accum = 0.0F;
    58.                 frames = 0;
    59.             }
    60.         }
    61.     }
    62. }
     
  2. medvedya2012

    medvedya2012

    Joined:
    May 27, 2014
    Posts:
    41
    I tried to run on IOS on iPad Mini, animator works fine with structure values.
     
  3. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,731
    It's a known bug about structs and is being worked on.
    As on performance on the phone, have you used Debug configuration? There is a big performance difference between Debug and Release/Master builds, especialy on lower end-devices like phones.
     
  4. medvedya2012

    medvedya2012

    Joined:
    May 27, 2014
    Posts:
    41
    I had used Debug configuration. I've just builded with "Release" configuration and got good performance.
    Thanks for help.
    I'll be wait for fix bug with struct.
     
  5. vicenterusso

    vicenterusso

    Joined:
    Jan 8, 2013
    Posts:
    130
    Is this fixed?
     
  6. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,731
    Yes, quite a while ago. Unless it's a new corner case.