Timeline Asset Broken

I was renaming my assets by hand via windows explorer, and managed to somehow completely break a few of my timeline assets. You can see in the screenshot what it looks like now. How do I reverse this? I’d rather not redo these timelines!

3350547--262068--Unity_2018-01-11_09-48-17.png

Restore them using source control, that’s what you usually do after an experiment.

some of these were not in source control, I was renaming them because I was about to commit them, I need a more unity level fix (perhaps some AssetDatabase manipulation of the files?)

If you write a script and call AssetDatabase.SetMainObject on the timeline, I believe it should fix the problem.

Hmm,
yeah, SetMainObject for fixing the nesting.

And if there are references broken inside the animations themselves you can actually edit the “name” in the animation window and if you set it correctly that will even fix problems where the animation system cannot find some properties! (just click twice slowly to enter edit mode)

Yep SetMainObject did the trick, thanks everyone. For anyone curious I wrote this little script to fix it. After you’ve installed it, just right click the broken timeline in the project view and select “Fix Broken Timeline Asset” from the context menu.

using UnityEngine;
using UnityEditor;

public class BrokenAssetFixer
{
    [MenuItem("Assets/Fix Broken Timeline Asset")]
    public static void FixBrokenAsset ()
    {
        Object selection = Selection.activeObject;

        string assetPath = AssetDatabase.GetAssetPath(selection);

        Object[] subAssets = AssetDatabase.LoadAllAssetsAtPath(assetPath);
        foreach (Object subAsset in subAssets)
        {
            if (subAsset is UnityEngine.Timeline.TimelineAsset)
            {
                AssetDatabase.SetMainObject(subAsset, assetPath);
            }
        }

        AssetDatabase.ImportAsset(assetPath);
        AssetDatabase.Refresh();
    }
}