Search Unity

Problem with animation material parameters in Unity4.3

Discussion in 'Animation' started by luanflora, Nov 17, 2013.

  1. luanflora

    luanflora

    Joined:
    Nov 1, 2013
    Posts:
    5
    I'm trying to animate the renderer's param with animation, like the color of the material. It works well in 4.2, but after a upgrade the unity3D to 4.3, it can't work anymore.

    I can animate the transform, position or else.

    When I try to animate a color param of my material, the old param in the inspector became red, I don't know what's that means.It seems like everything work correctly by the curves, but the color never changed.

    Is that a bug of 4.3?
     
  2. deathguide

    deathguide

    Joined:
    Aug 4, 2012
    Posts:
    6
    I also have this problem. Old animation still works, but I can not author a new one with material animation
     
  3. instruct9r

    instruct9r

    Joined:
    Aug 1, 2012
    Posts:
    148
  4. AMO_Noot

    AMO_Noot

    Joined:
    Aug 14, 2012
    Posts:
    433
    Hi Instruct9r; thanks for the quick video on the new animator. But like the others, I think the main problem is that legacy animations are not modifiable anymore if they involve material/renderer animation. I'm assuming it's a bug...
     
  5. Yohann1172

    Yohann1172

    Joined:
    May 1, 2013
    Posts:
    6
    I'm having the same prob. Did anyone already submit a bug report?
     
  6. kfc

    kfc

    Joined:
    Dec 17, 2010
    Posts:
    27
    Hi,

    I think I've encounter this issue too.
    $Screen Shot 2013-11-28 at 6.36.11 PM.png
    In this attachment, I've selected on a legacy animation material I've animated in earlier version where by I can animate the texture offset easily from animation editor.

    I can't be able to use the animation editor to animate texture offset now. I believe there's some other missing attributes too. But texture offset is the most obvious at the moment.

    $Screen Shot 2013-11-28 at 6.34.43 PM.png
    Texture offset can't be found in animation editor of unity 4.3 now.
     
  7. WFTO_JWong

    WFTO_JWong

    Joined:
    Feb 4, 2013
    Posts:
    7
    This is 100% most definitely a bug/issue.

    The necessary parameters for editing "OFFSET" and "TILING" simply do not exist in Unity 4.3, thus making it impossible to edit/create UV animations targeting materials. This is evidenced by the red highlight when you attempt to edit a UV anim from 4.2.

    Bummer

    Hope Unity gets on this and fixes this :confused: . Making UV mesh animations used to be really slick, something that could be done in mere minutes.
     
  8. maxceem

    maxceem

    Joined:
    Mar 25, 2013
    Posts:
    2
  9. PhosfiendSystems

    PhosfiendSystems

    Joined:
    May 19, 2013
    Posts:
    1
    Ya, this really sucks. Definitely a huge obstacle for me in late-stage work on FRACT OSC. Please fix this Unity, this one is no fun
     
  10. kimsungwhee

    kimsungwhee

    Joined:
    Jan 11, 2014
    Posts:
    1
    you can set as below
    $material.png
     
  11. sterlingr

    sterlingr

    Joined:
    Jul 12, 2013
    Posts:
    4
    I found the solution!!!! Well, another user did, but I'm posting it!

    The problem is that Unity has changed its Material keyframe formatting when it saves animation clips. If you need to use the legacy animation system here's how to fix it:

    Change animation type to 1
    open the clip in a text editor, and replace classID 23 with classID 21
    Still in the text editor, remove material. from the beginning of each Material attribute

    Please post if this worked or didn't work for you. And spread the word!

    -Sterling Sr. Animator - Proletariat Inc.
     
  12. Steven-Walker

    Steven-Walker

    Joined:
    Oct 27, 2010
    Posts:
    38
    Using Unity 4.3.4 and am running into a similar issue trying to animate a float property on a custom shader. I can create a curve, but it doesn't affect the material at all whether in edit mode or playing. This worked fine in versions prior to the new Animation window. I've created a stripped down example of the project and have submitted it as a bug.
     
  13. adrianzarp

    adrianzarp

    Joined:
    Feb 25, 2014
    Posts:
    4
    I also noticed that problem upon upgrade, but, at least about the texture Offset, I think that it only changed menu. I found it in this option: Material._Main Tex_ST
    There you can animate the Offset and tiles.
     
  14. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    1. I don't have scroll bars in the curve window that allows me to scroll around to see my curve. If I want to make a big curve I can't scroll up or down to reach the value to which I want to drag the keyframe.

    2. I can'T set my animations to anything shorter that 1 second.

    I have Unity Pro 4.3.4 on OSX 10.8.5. The previous version of Unity did not have these problems.

    $WTF.png


    Forget it. Restarting Unity fixed it and I found to shorten the animation length that you have to do it in the Dope Sheet.
     
    Last edited: Mar 1, 2014
  15. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    this is not fixed yet??
     
  16. mikhail111777

    mikhail111777

    Joined:
    Feb 8, 2013
    Posts:
    84
    It looks like this BUG has not been fixed, or there is just another regression in 4.6.1p1
     
  17. Modest.Blue

    Modest.Blue

    Joined:
    Dec 25, 2014
    Posts:
    4
    same problem with me, unable to animate the material properties.
     
  18. ZFarago

    ZFarago

    Joined:
    Aug 13, 2012
    Posts:
    155
    Same problem...
    1.) I am unable to put new keyframes to Legacy animations, altough I am able to move existing keys. This clips are palys well.
    2.) Material offset / tiling are not working in the new animation type.
    3.) The new animation type doesn't support material blocks You can not animate even the colors separately.

    Based on the trick with changing ID's, I made a small tool that can switch between the two types of animations ( legacy and mecanim), to both directions. This means that I can switch an old animation to mecanim type, able to modify and switch it back, so it will animate fine. The only thing I can not solve yet is the animating of mateiral blocks as seems they are not exist in the mecanim animation clip.
     
  19. hicks

    hicks

    Joined:
    Nov 24, 2013
    Posts:
    13
    I have a different problem. I'm animating the color of a material. Now, I want to adjust another renderer's alpha in relation to the animated material color. So, I want to get the current main color ("_Color"). However, I can't find a way to get the current color that the editor is showing. Neither combination of the following works: sharedMaterial, material, color, GetColor("_Color"), querying in Update, querying in LateUpdate.

    Someone else has had this problem, too: http://answers.unity3d.com/questions/935784/after-animating-a-custom-materialshader-parameter.html

    Is there really no way we can get the current main color of a renderer, which is animated by an animator?

    Ok, sorry, found the answer myself:
    http://answers.unity3d.com/answers/1134715/view.html
     
    Last edited: Jan 28, 2016
  20. G1NurX

    G1NurX

    Joined:
    Dec 25, 2012
    Posts:
    69
    The way to hack-fix it mentioned by sterlingr works.
    But you have to enable textual asset serialization.
    In fact, we can do it in script (for example, an implementation of AssetPostProcessor).
    Here is code snippet of a context menu implementation.
    It only works in Unity 4.x. The hack won't work in Unity 5.x .

    *I coded it in Unity 5.x, you may have to do some modification in Unity 4.x*

    Code (CSharp):
    1. public static class LegacyAnimationFixer
    2. {
    3.     [MenuItem("Assets/Convert to Legacy Animation", validate = true)]
    4.     static bool CanConvert()
    5.     {
    6.         bool canConvert = false;
    7.  
    8.         foreach (var obj in Selection.objects)
    9.         {
    10.             if (obj is AnimationClip)
    11.                 canConvert = true;
    12.         }
    13.  
    14.         return canConvert;
    15.     }
    16.  
    17.     [MenuItem("Assets/Convert to Legacy Animation", validate = false)]
    18.     static void ConvertToLegacyAnim()
    19.     {
    20.         foreach (var obj in Selection.objects)
    21.         {
    22.             AnimationClip clip = obj as AnimationClip;
    23.             if (clip != null)
    24.                 DoConvert(clip);
    25.         }
    26.     }
    27. #if UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6
    28.  
    29.     private static MethodInfo getAnimationType = null;
    30.  
    31.     static void DoConvert(AnimationClip clip)
    32.     {
    33.         bool dirty = false;
    34.  
    35.         if (GetAnimationType(clip) != ModelImporterAnimationType.Legacy)
    36.         {
    37.             AnimationUtility.SetAnimationType(clip, ModelImporterAnimationType.Legacy);
    38.             dirty = true;
    39.         }
    40.  
    41.         EditorCurveBinding[] bindings = AnimationUtility.GetCurveBindings(clip);
    42.         List<AnimationCurve> curves = new List<AnimationCurve>();
    43.  
    44.         bool rebuildClip = false;
    45.  
    46.         for (int i = 0; i < bindings.Length; i++)
    47.         {
    48.             curves.Add(AnimationUtility.GetEditorCurve(clip, bindings[i]));
    49.  
    50.             var binding = bindings[i];
    51.  
    52.             if (binding.propertyName.StartsWith("Material.") && binding.type == typeof(MeshRenderer))
    53.             {
    54.                 rebuildClip = true;
    55.                 binding.propertyName = binding.propertyName.Substring("Material.".Length);
    56.                 binding.type = typeof(Material);
    57.                 bindings[i] = binding;
    58.             }
    59.         }
    60.  
    61.         if (rebuildClip)
    62.         {
    63.             dirty = true;
    64.  
    65.             clip.ClearCurves();
    66.  
    67.             for (int i = 0; i < bindings.Length; i++)
    68.             {
    69.                 AnimationUtility.SetEditorCurve(clip, bindings[i], curves[i]);
    70.             }
    71.         }
    72.  
    73.         if (dirty)
    74.         {
    75.             EditorUtility.SetDirty(clip);
    76.         }
    77.     }
    78.  
    79.     static ModelImporterAnimationType GetAnimationType(AnimationClip clip)
    80.     {
    81.         if (getAnimationType == null)
    82.         {
    83.             getAnimationType = typeof(AnimationUtility).GetMethod("GetAnimationType", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
    84.         }
    85.  
    86.         return (ModelImporterAnimationType)getAnimationType.Invoke(null, new object[] { clip });
    87.     }
    88. #else
    89.  
    90.     static void DoConvert(AnimationClip clip)
    91.     {
    92.         bool dirty = false;
    93.  
    94.         if (!clip.legacy)
    95.         {
    96.             clip.legacy = true;
    97.             dirty = true;
    98.         }
    99.  
    100.         EditorCurveBinding[] bindings = AnimationUtility.GetCurveBindings(clip);
    101.         List<AnimationCurve> curves = new List<AnimationCurve>();
    102.  
    103.         bool rebuildClip = false;
    104.  
    105.         for (int i = 0; i < bindings.Length; i++)
    106.         {
    107.             curves.Add(AnimationUtility.GetEditorCurve(clip, bindings[i]));
    108.  
    109.             var binding = bindings[i];
    110.  
    111.             if (binding.propertyName.StartsWith("material.") && binding.type == typeof(MeshRenderer))
    112.             {
    113.                 rebuildClip = true;
    114.                 binding.propertyName = binding.propertyName.Substring("material.".Length);
    115.                 binding.type = typeof(Material);
    116.                 bindings[i] = binding;
    117.             }
    118.         }
    119.  
    120.         if (rebuildClip)
    121.         {
    122.             dirty = true;
    123.  
    124.             clip.ClearCurves();
    125.  
    126.             for (int i = 0; i < bindings.Length; i++)
    127.             {
    128.                 AnimationUtility.SetEditorCurve(clip, bindings[i], curves[i]);
    129.             }
    130.         }
    131.  
    132.         if (dirty)
    133.         {
    134.             EditorUtility.SetDirty(clip);
    135.         }
    136.     }
    137.  
    138. #endif
    139. }
    140.  
     
    Last edited: Apr 5, 2016
  21. Stents

    Stents

    Joined:
    Jan 23, 2014
    Posts:
    18
    I can't believe this bug still hasn't been fixed??
    The fix mentioned by sterlingr and your script G1NurX both work around the issue somewhat, however artists can't really properly author or test legacy UV animations within unity while this bug exists (unless I'm missing something?)

    It would be nice if this bug could be fixed, after being reported over 2 years ago....