Search Unity

Question Generating an animator via code, cant set the sync layer correctly.

Discussion in 'Animation' started by FelipeReis, Apr 23, 2021.

  1. FelipeReis

    FelipeReis

    Joined:
    Jan 27, 2012
    Posts:
    38
    Hi I am trying to generate an animator via code, but the part where i say which sync layer it should point to is not working as expected.

    var controller =
    AnimatorController.CreateAnimatorControllerAtPath("Assets/TEMP/GeneratedController.controller");
    controller.AddLayer("Layer 1");
    controller.AddLayer("Layer 2");
    controller.layers[1].syncedLayerIndex = 1;


    According to the reference this should cause the layer to act as a sync layer,
    https://docs.unity3d.com/ScriptReference/Animations.AnimatorControllerLayer-syncedLayerIndex.html

    This is not working,
    Am I missing something?