Exemplo n.º 1
0
    public void CreateNewAnimation(bool isAudioBased, int audioFileIndex, string newAnimFileName, float newTime)
    {
        if (newAnimFileName != "")
        {
            string newAudioName = "";
            if (isAudioBased)
            {
                newAudioName = tagarela.audioFiles[audioFileIndex].name;
            }

            TagarelaMorphTarget _MorphTarget = new TagarelaMorphTarget();
            _MorphTarget.Populate(tagarela.smrTotal);

            guiTimeline = new TagarelaTimelineUI(newTime);
            guiTimeline.AddKeyframe(0f, _MorphTarget);

            guiTimelineSegment = new TagarelaTimelineSegmentUI(newTime);

            if (TagarelaFileManager.Save(newAnimFileName, tagarela.smrTotal, guiTimeline.keyframeSet, 0, newAudioName, newTime))
            {
                TextAsset newFile = AssetDatabase.LoadMainAssetAtPath("Assets/Tagarela/System/Animations/" + newAnimFileName + ".xml") as TextAsset;
                AssetDatabase.Refresh();
                tagarela.Clean();
                tagarela.animationFiles.Add(newFile);

                CleanVars();
                dialog = ScreenDialog.InitialScreen;
                Repaint();
                Update();

                LoadAnimationFile(tagarela.animationFiles[tagarela.animationFiles.Count - 1]);
            }
        }
    }
Exemplo n.º 2
0
    public void LoadAnimationFile(TextAsset file)
    {
        //RefreshMeshlist();
        RefreshAudiolist();
        tagarela.Clean();
        CleanVars();

        settings = TagarelaFileManager.Load(file);
        lastSelectionGameObjectEditing = Selection.activeGameObject;
        fileName = file.name;
        guiTimeline = new TagarelaTimelineUI(settings.animationTime);
        audioPreviewSpectrum = null;
        SelectedAudioclip = null;
        tagarela.audio.clip = null;
        tagarela.isPlaying = false;
        playMode = PlayMode.stopped;

        if (settings.audioFile != null)
        {

            for (int i = 0; i < tagarela.audioFiles.Count; i++)
            {

                if (settings.audioFile == tagarela.audioFiles[i].name)
                {
                    SelectedAudioclip = tagarela.audioFiles[i];
                    tagarela.audio.clip = tagarela.audioFiles[i];
                    audioPreviewSpectrum = TagarelaAudioSpectrum.CreatePreview(SelectedAudioclip, 1024, 64, new Color(150f / 255f, 200f / 255f, 25f / 255f, 0.8f), TagarelaAudioSpectrum.PreviewType.both);
                    audioPreviewSpectrum.hideFlags = HideFlags.DontSave;
                }
            }
        }

        //  CARREGA O ARQUIVO XML
        //configurações principais

        if (settings.meshList.id != null)
        {
            guiTimeline.keyframeSet = new List<TagarelaTimelineUI.TLkeyframe>();

            for (int i = 0; i < settings.keyframes.values.Length; i++)
            {

                TagarelaMorphTarget _MorphTarget = new TagarelaMorphTarget();
                _MorphTarget.Populate(tagarela.morphTargets);

                for (int j = 0; j < settings.keyframes.sliderSettings[i].Length; j++)
                {
                    float[] sliders = settings.keyframes.sliderSettings[i];
                    if (j < tagarela.morphTargets.Count)
                    {
                        //tagarela.morphTargets[j].hideFlags = HideFlags.DontSave;
                        _MorphTarget.sliderValue[j] = sliders[j];
                    }
                }
                guiTimeline.AddKeyframe(settings.keyframes.values[i], _MorphTarget);

            }
        }
        else
        {
            guiTimeline.keyframeSet = new List<TagarelaTimelineUI.TLkeyframe>();
            TagarelaMorphTarget _MorphTarget = new TagarelaMorphTarget();
            _MorphTarget.Populate(tagarela.morphTargets);
            guiTimeline.AddKeyframe(0f, _MorphTarget);

        }

        //Update the file settings
        settings = TagarelaFileManager.UpdateSettings(tagarela.morphTargets, guiTimeline.keyframeSet, tagarela.neutralMesh.vertexCount, settings.audioFile, guiTimeline.totalValue);
        guiTimelineSegment = new TagarelaTimelineSegmentUI(settings.animationTime);

        tagarela.OpenFile(file);

        timeNormalized = 0f;
        playMode = PlayMode.stopped;
        lastKeyframeSelected = -1;

        lastKeyframeSelected = guiTimeline.selectedIndex;
        updateMorphValue = guiTimeline.selectedValue;

        updateTimeline = true;

        if (settings != null && Selection.objects.Length == 1)
        {
            dialog = ScreenDialog.Timeline;
        }
    }
Exemplo n.º 3
0
    public void CreateNewAnimation(bool isAudioBased, int audioFileIndex, string newAnimFileName, float newTime)
    {
        if (newAnimFileName != "")
        {

            string newAudioName = "";
            if (isAudioBased) newAudioName = tagarela.audioFiles[audioFileIndex].name;

            TagarelaMorphTarget _MorphTarget = new TagarelaMorphTarget();
            _MorphTarget.Populate(tagarela.morphTargets);

            guiTimeline = new TagarelaTimelineUI(newTime);
            guiTimeline.AddKeyframe(0f, _MorphTarget);

            guiTimelineSegment = new TagarelaTimelineSegmentUI(newTime);

            if (TagarelaFileManager.Save(newAnimFileName, tagarela.morphTargets, guiTimeline.keyframeSet, tagarela.neutralMesh.vertexCount, newAudioName, newTime))
            {
                TextAsset newFile = AssetDatabase.LoadMainAssetAtPath("Assets/Tagarela/System/Animations/" + newAnimFileName + ".xml") as TextAsset;
                AssetDatabase.Refresh();
                tagarela.Clean();
                tagarela.animationFiles.Add(newFile);

                CleanVars();
                dialog = ScreenDialog.InitialScreen;
                Repaint();
                Update();

                LoadAnimationFile(tagarela.animationFiles[tagarela.animationFiles.Count - 1]);
            }

        }
    }
Exemplo n.º 4
0
    public void LoadAnimationFile(TextAsset file)
    {
        RefreshAudiolist();
        tagarela.Clean();
        CleanVars();

        settings = TagarelaFileManager.Load(file);
        lastSelectionGameObjectEditing = Selection.activeGameObject;
        fileName             = file.name;
        guiTimeline          = new TagarelaTimelineUI(settings.animationTime);
        audioPreviewSpectrum = null;
        SelectedAudioclip    = null;
        tagarela.audio.clip  = null;
        tagarela.isPlaying   = false;
        playMode             = PlayMode.stopped;


        if (settings.audioFile != null)
        {
            for (int i = 0; i < tagarela.audioFiles.Count; i++)
            {
                if (settings.audioFile == tagarela.audioFiles[i].name)
                {
                    SelectedAudioclip              = tagarela.audioFiles[i];
                    tagarela.audio.clip            = tagarela.audioFiles[i];
                    audioPreviewSpectrum           = TagarelaAudioSpectrum.CreatePreview(SelectedAudioclip, 1024, 64, new Color(150f / 255f, 200f / 255f, 25f / 255f, 0.8f), TagarelaAudioSpectrum.PreviewType.both);
                    audioPreviewSpectrum.hideFlags = HideFlags.DontSave;
                }
            }
        }

        //  CARREGA O ARQUIVO XML
        //configurações principais

        if (settings.meshList.id != null)
        {
            guiTimeline.keyframeSet = new List <TagarelaTimelineUI.TLkeyframe>();

            for (int i = 0; i < settings.keyframes.values.Length; i++)
            {
                TagarelaMorphTarget _MorphTarget = new TagarelaMorphTarget();
                _MorphTarget.Populate(tagarela.smrTotal);

                for (int j = 0; j < settings.keyframes.sliderSettings[i].Length; j++)
                {
                    float[] sliders = settings.keyframes.sliderSettings[i];

                    if (j < tagarela.smrTotalBlendShapesCount)
                    {
                        //tagarela.morphTargets[j].hideFlags = HideFlags.DontSave;
                        _MorphTarget.sliderValue[j] = sliders[j];
                    }
                }
                guiTimeline.AddKeyframe(settings.keyframes.values[i], _MorphTarget);
            }
        }
        else
        {
            guiTimeline.keyframeSet = new List <TagarelaTimelineUI.TLkeyframe>();
            TagarelaMorphTarget _MorphTarget = new TagarelaMorphTarget();
            _MorphTarget.Populate(tagarela.smrTotal);
            guiTimeline.AddKeyframe(0f, _MorphTarget);
        }

        //Update the file settings
        settings           = TagarelaFileManager.UpdateSettings(tagarela.smrTotal, guiTimeline.keyframeSet, 0, settings.audioFile, guiTimeline.totalValue);
        guiTimelineSegment = new TagarelaTimelineSegmentUI(settings.animationTime);

        tagarela.OpenFile(file);

        timeNormalized       = 0f;
        playMode             = PlayMode.stopped;
        lastKeyframeSelected = -1;

        lastKeyframeSelected = guiTimeline.selectedIndex;
        updateMorphValue     = guiTimeline.selectedValue;

        updateTimeline = true;

        if (settings != null && Selection.objects.Length == 1)
        {
            dialog = ScreenDialog.Timeline;
        }
    }