Example #1
0
        /// <summary>
        /// Exports the resulting scene out to a .unitypackage, including all dependencies
        /// </summary>
        public static void Export()
        {
            // save the scene first
            UnityUtilities.PromptToSaveScene(SceneManager.GetActiveScene());

            UnityUtilities.ExportPackage(model.scenePath, model.sceneName);
        }
Example #2
0
        /// <summary>
        /// Run the shot assembly task with the given input
        /// </summary>
        public static void Process()
        {
            if (!ValidateData())
            {
                return;
            }
            PlayableDirector pd;

            // chcek if we're using an existing timeline or creating a new one
            if (!model.useExistingTimeline)
            {
                // do we need to make a new scene too?
                if (model.createNewScene)
                {
                    UnityUtilities.CreateNewScene(model.sceneName, model.scenePath);
                }
                pd = UnityUtilities.CreatePlayableDirector(model.timelineName, model.timelinePath);
            }
            else
            {
                pd = model.existingTimeline;
            }

            GenerateBaseTimelineTracks(pd);

            // set the scene selection to our new timeline so that we can scrub and see it
            Selection.activeObject = pd.gameObject;
        }
Example #3
0
        /// <summary>
        /// Create the playable director, timeline sequence and add all of the animation tracks to the timeline
        /// </summary>
        /// <param name="pd"></param>
        private static void GenerateBaseTimelineTracks(PlayableDirector pd)
        {
            var timelineAsset = pd.playableAsset as TimelineAsset;

            if (model.oneTrackPerAnim)
            {
                // for each animation in the list, we want to instance an actor, create a track and bind the clip
                foreach (var clip in model.animationList)
                {
                    var go = InstanceActorInScene();

                    var animTrack = timelineAsset.CreateTrack <AnimationTrack>(null, go.name);

                    // bind the track to our new actor instance
                    pd.SetGenericBinding(animTrack, go);

                    UnityUtilities.AddClipToAnimationTrack(animTrack, clip);
                }
            }
            else
            {
                var animTrack = timelineAsset.CreateTrack <AnimationTrack>(null, "Character Rig");

                // bind the track to our new actor instance
                var go = InstanceActorInScene();
                pd.SetGenericBinding(animTrack, go);

                // add the clips to Timeline
                foreach (var clip in model.animationList)
                {
                    UnityUtilities.AddClipToAnimationTrack(animTrack, clip);
                }
            }

            // add cinemachine stuff
            //var mainCam = GameObject.FindObjectOfType<Camera>();
            //var brain = mainCam.gameObject.AddComponent<CinemachineBrain>();

            //var go = new GameObject();
            //go.name = "LookDev VCam";
            //var vcam = go.AddComponent<CinemachineVirtualCamera>();
            //vcam.m_Follow = model.actorSceneInstance.transform;
            //vcam.m_LookAt = model.actorSceneInstance.transform;
            //// set the Body & Aim for the vcam
            //var vcamAim = vcam.AddCinemachineComponent<CinemachineComposer>();
            //var vcamBody = vcam.AddCinemachineComponent<CinemachineFramingTransposer>();

            //// and add a cinemachine track so we can see what we're animating
            //var cmTrack = timelineAsset.CreateTrack<CinemachineTrack>(null,  "Brain");

            //pd.SetGenericBinding(cmTrack, brain);

            //var cmClip = cmTrack.CreateDefaultClip();
            //cmClip.duration = pd.duration;
            //cmClip.displayName = go.name;
            //var cmAsset = cmClip.asset as CinemachineShot;
            //cmAsset.VirtualCamera.exposedName = "LookdevVCam";
            //pd.SetReferenceValue("LookdevVCam", vcam);
        }