Esempio n. 1
0
    private void CreateSlide()
    {
        if (!presentationManager)
        {
            EditorUtility.DisplayDialog("Error", "please press setup button first", "OK");
            return;
        }

        CreateSlidesFolder();

        GameObject s = new GameObject(slideName, typeof(PresentationSlide));

        s.transform.SetParent(presentationManager.transform);
        Undo.RegisterCreatedObjectUndo(s, "PresentationSlide Create");
        AssetDatabase.CreateAsset(TimelineAsset.CreateInstance(typeof(TimelineAsset)), "Assets/SlidesTimeLine/" + slideName + ".playable");

        if (!playableDirector.GetComponent <Animator>())
        {
            playableDirector.gameObject.AddComponent <Animator>();
        }


        playableDirector.playableAsset = AssetDatabase.LoadAssetAtPath("Assets/SlidesTimeLine/" + slideName + ".playable", typeof(TimelineAsset)) as PlayableAsset;

        // Add Animation Track
        TrackAsset t = (playableDirector.playableAsset as TimelineAsset).CreateTrack(typeof(AnimationTrack), null, "");

        playableDirector.SetGenericBinding(t, playableDirector.GetComponent <Animator>());

        // Fetch Slides
        presentationManager.FindAllSlide();

        // Add the new timeline to presentation manager
        presentationManager.AddNewSlideTimeLine(playableDirector.playableAsset);
    }