Search Unity

[Unity 4.6] How to change skined mesh render after optimize game objects

Discussion in 'General Discussion' started by sylar-huang, Aug 22, 2015.

  1. sylar-huang

    sylar-huang

    Joined:
    Dec 13, 2013
    Posts:
    4
    I found skined mesh render's bones empty after "Optimize game objects" enabled in the model rig, so I can't rebuild bones and replace with different skeleton share the same bones hierarchy like before . These codes are work well without this thing enabled

    SkinnedMeshRenderer s = go.GetComponentInChildren<SkinnedMeshRenderer>();

    nbones.Clear();
    bones = _src.GetComponentsInChildren<Transform>();

    foreach (Transform bone in s.bones) {
    foreach (Transform old in bones) {
    if (old.name != bone.name) {
    continue;
    }
    nbones.Add(old);
    break;
    }
    }

    _renderer.bones = nbones.ToArray();
    _renderer.sharedMesh = s.sharedMesh;
    _renderer.materials = s.materials;
     
    Last edited: Aug 22, 2015
  2. sylar-huang

    sylar-huang

    Joined:
    Dec 13, 2013
    Posts:
    4
    somebody help o_O;)
     
  3. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
    Do not optimize them, because that's one effect of optimization(and probably the only one).
     
  4. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,203
    You'd have a better chance at answers if you post in the scripting section. Additionally you will want to use code tags.