Search Unity

Unity animation failed to animate a script variable on my windows phone.

Discussion in 'Windows' started by NeoSu, Aug 11, 2013.

  1. NeoSu

    NeoSu

    Joined:
    Aug 11, 2013
    Posts:
    12
    It works just fine in my Unity editor until I deploy the game onto my HTC x8.
    Anyone has the same problem?
    Any fix?:confused:
     
    Last edited: Aug 11, 2013
  2. NeoSu

    NeoSu

    Joined:
    Aug 11, 2013
    Posts:
    12
    For the script variable I mean the public monobehavior variable of course :)
     
  3. namine

    namine

    Joined:
    Mar 1, 2013
    Posts:
    21
    My understanding is that the editor uses Mono whereas WP8 device uses a special .NET version.
    Is there an error in Visual Studio ?
    Can you post the code that is crashing ?
     
  4. NeoSu

    NeoSu

    Joined:
    Aug 11, 2013
    Posts:
    12
    Thx for the reply namine.
    The app didn't crash and there was no error. It's the animations didn't alter the public vars of a component.
    My game does keep running but it looks weird.
     
    Last edited: Aug 12, 2013
  5. NeoSu

    NeoSu

    Joined:
    Aug 11, 2013
    Posts:
    12
  6. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,916
  7. NeoSu

    NeoSu

    Joined:
    Aug 11, 2013
    Posts:
    12
    It looks like I got to find another way to do it. Thanks.
     
    Last edited: Aug 12, 2013
  8. sonofbryce

    sonofbryce

    Joined:
    May 19, 2009
    Posts:
    111
    This is a really sorry limitation. Does anyone have any ways around this? My game kind of relies on this feature so it'll take a ton of work to redo this animation.
     
  9. rumorgames

    rumorgames

    Joined:
    Nov 28, 2012
    Posts:
    48
    Well, the straightforward fix is to replace your animations with scripts. That's probably impractical for you if you have lots of complex animations, though.

    To work around the issue, I created a system to extract animation curves from animations and save them into adapter scripts that know the variables they're supposed to modify. Unfortunately, the adapter scripts need to be customized for each variable, since Reflection is not supported in Windows Store apps (which is probably why this limitation exists in the first place).

    The gist of the process is:
    1. Editor script reads animation curves from animations, and saves them as new "extracted curve" component on the game object
    2. Remove all extracted curves that don't need adaptation in the editor (for example, animating the transform)
    3. Write an adapter component that binds the state of the extracted animation curve to the variable you want modified

    To cut down on complexity, I have the extracted curve component update itself to match the current animation state at runtime, so the adapter scripts simply read the curve state and apply it and don't have to worry about timekeeping. Altogether, it's a bunch of upfront work, but it has the benefit of being easy to reverse once this feature is eventually supported (simply remove all the extracted curve and adapter scripts and let the animations do their thing).