Exemplo n.º 1
0
    //***************************************************
    // Saving ...
    // **************************************************
    public static TagarelaFileStructure UpdateSettings(List <SkinnedMeshRenderer> meshList, List <TagarelaTimelineUI.TLkeyframe> KeyframeSet, int MeshVertexCount, string AudioFile, float TotalTime)
    {
        // we need soemthing to store the information into
        FileData = new TagarelaFileStructure();

        FileData.animationTime   = TotalTime;
        FileData.audioFile       = AudioFile;
        FileData.meshVertexCount = MeshVertexCount;

        string[] tempSaveData_Id          = new string[meshList.Count];
        string[] tempSaveData_Description = new string[meshList.Count];
        for (int i = 0; i < meshList.Count; i++)
        {
            tempSaveData_Id[i]          = meshList[i].name;
            tempSaveData_Description[i] = meshList[i].name;
        }
        FileData.meshList.id          = tempSaveData_Id;
        FileData.meshList.description = tempSaveData_Description;

        FileData.keyframes.sliderSettings = new List <float[]>();
        FileData.keyframes.values         = new float[KeyframeSet.Count];
        for (int i = 0; i < KeyframeSet.Count; i++)
        {
            //UI_TimeLine.TLkeyframe temp_keyframe = (UI_TimeLine.TLkeyframe);
            FileData.keyframes.sliderSettings.Add(KeyframeSet[i].morphSliders.sliderValue.ToArray());
            FileData.keyframes.values[i] = KeyframeSet[i].value;
            //FileData.keyframes.values[i] = (temp_keyframe.Value);
        }

        return(FileData);
    }
Exemplo n.º 2
0
    public void Clean()
    {
        audio.clip = null;

        keyValues       = null;
        _SliderSettings = null;

        listademesh    = null;
        v3_listademesh = null;

        isPlaying   = false;
        editionMode = false;
        timer       = 0;
        basemesh    = null;

        timeline = null;

        keyframeCurrentTime  = 0;
        keyframeDurationTime = 0;
        keyframeCurrent      = 0;
        keyframeNew          = 0;

        morphFrom = null;
        morphTo   = null;

        settings = null;
    }
Exemplo n.º 3
0
    public void ChangeAnimLength(float newLength)
    {
        //Update the file settings

        guiTimeline.totalValue = newLength;

        List <TagarelaTimelineUI.TLkeyframe> keySet = new List <TagarelaTimelineUI.TLkeyframe>(guiTimeline.keyframeSet);

        keySet.RemoveAll(item => item.value > newLength);


        guiTimeline.keyframeSet = keySet;

        settings = TagarelaFileManager.UpdateSettings(tagarela.smrTotal, guiTimeline.keyframeSet, 0, "", guiTimeline.totalValue);

        //guiTimeline.UpdateSelection();
        guiTimelineSegment.totalValue           = newLength;
        guiTimelineSegment.KeyframeSet[0].Value = 0;
        guiTimelineSegment.KeyframeSet[1].Value = newLength;
        guiTimelineSegment.UpdateSelection();

        settings.animationTime = newLength;

        Repaint();
        tagarela.settings = settings;
        tagarela.BuildTimeline();
        updateTimeline = true;

        Repaint();
        Update();
        playMode = PlayMode.currentTime;
    }
Exemplo n.º 4
0
    public void OpenFile(TextAsset file)
    {
        Tagarela_loader LoadFile = new Tagarela_loader();

        settings   = LoadFile.Load(file);
        audio.clip = null;
        audio.clip = audioFiles.Find(delegate(AudioClip a) { return(a.name == settings.audioFile); });
    }
Exemplo n.º 5
0
 public static TagarelaFileStructure Load(TextAsset file)
 {
     _data = file.text;
     if (_data.ToString() != "")
     {
         FileData = (TagarelaFileStructure)DeserializeObject(_data);
     }
     return(FileData);
 }
Exemplo n.º 6
0
 public static TagarelaFileStructure Load(TextAsset file)
 {
     _data = file.text;
     if (_data.ToString() != "")
     {
         FileData = (TagarelaFileStructure)DeserializeObject(_data);
     }
     return FileData;
 }
Exemplo n.º 7
0
    //***************************************************
    // Saving ...
    // **************************************************
    public static bool NewFile(string filename, int MeshVertexCount)
    {
        // Where we want to save and load to and from
        _FileLocation = Application.dataPath + "/Tagarela/System/Animations/";
        _FileName     = filename + ".xml";

        // we need soemthing to store the information into
        FileData = new TagarelaFileStructure();
        FileData.animationTime   = 0f;
        FileData.audioFile       = "";
        FileData.meshVertexCount = MeshVertexCount;

        // Time to creat our XML!
        _data = SerializeObject(FileData);
        // This is the final resulting XML from the serialization process
        return(CreateXML());
    }
Exemplo n.º 8
0
    //***************************************************
    // Saving ...
    // **************************************************
    public static bool NewFile(string filename, int MeshVertexCount)
    {
        // Where we want to save and load to and from
        _FileLocation = Application.dataPath + "/Tagarela/System/Animations/";
        _FileName = filename + ".xml";

        // we need soemthing to store the information into
        FileData = new TagarelaFileStructure();
        FileData.animationTime = 0f;
        FileData.audioFile = "";
        FileData.meshVertexCount = MeshVertexCount;

        // Time to creat our XML!
        _data = SerializeObject(FileData);
        // This is the final resulting XML from the serialization process
        return CreateXML();
    }
    public void CleanVars()
    {
        RestoreOriginalMesh();

        if (tagarela.mainObject.GetComponent <MeshFilter>())
        {
            tagarela.mainObject.GetComponent <MeshFilter>().sharedMesh.vertices = tagarela.neutralMesh.vertices;
        }
        else if (tagarela.mainObject.GetComponent <SkinnedMeshRenderer>())
        {
            tagarela.mainObject.GetComponent <SkinnedMeshRenderer>().sharedMesh.vertices = tagarela.neutralMesh.vertices;
        }

        updateMorph                    = false;
        tagarela.audio.clip            = null;
        lastSelectionGameObjectEditing = null;
        log_msg  = "";
        fileName = "";
        settings = null;
    }
Exemplo n.º 10
0
    public void Clean()
    {
        audio.clip = null;

        isPlaying   = false;
        editionMode = false;
        timer       = 0;

        timeline = null;

        keyframeCurrentTime  = 0;
        keyframeDurationTime = 0;
        keyframeCurrent      = 0;
        keyframeNew          = 0;

        morphFrom = null;
        morphTo   = null;

        settings = null;
    }
Exemplo n.º 11
0
    //***************************************************
    // Saving ...
    // **************************************************
    public static bool Save(string filename, List <SkinnedMeshRenderer> meshList, List <TagarelaTimelineUI.TLkeyframe> KeyframeSet, int MeshVertexCount, string AudioFile, float TotalTime)
    {
        // Where we want to save and load to and from
        _FileLocation = Application.dataPath + "/Tagarela/System/Animations/";
        _FileName     = filename + ".xml";

        // we need soemthing to store the information into
        FileData = new TagarelaFileStructure();

        FileData.animationTime   = TotalTime;
        FileData.audioFile       = AudioFile;
        FileData.meshVertexCount = MeshVertexCount;

        string[] tempSaveData_Id          = new string[meshList.Count];
        string[] tempSaveData_Description = new string[meshList.Count];
        for (int i = 0; i < meshList.Count; i++)
        {
            tempSaveData_Id[i]          = meshList[i].name;
            tempSaveData_Description[i] = meshList[i].name;
        }
        FileData.meshList.id          = tempSaveData_Id;
        FileData.meshList.description = tempSaveData_Description;

        FileData.keyframes.sliderSettings = new List <float[]>();
        FileData.keyframes.values         = new float[KeyframeSet.Count];
        for (int i = 0; i < KeyframeSet.Count; i++)
        {
            //UI_TimeLine.TLkeyframe temp_keyframe = (UI_TimeLine.TLkeyframe);
            FileData.keyframes.sliderSettings.Add(KeyframeSet[i].morphSliders.sliderValue.ToArray());
            FileData.keyframes.values[i] = KeyframeSet[i].value;
            //FileData.keyframes.values[i] = (temp_keyframe.Value);
        }

        //FileData.Keyframes._single_keyframe =

        // Time to creat our XML!
        _data = SerializeObject(FileData);
        // This is the final resulting XML from the serialization process
        return(CreateXML());
    }
Exemplo n.º 12
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.º 13
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;
        }
    }
Exemplo n.º 14
0
    public void Clean()
    {
        audio.clip = null;

        keyValues = null;
        _SliderSettings = null;

        listademesh = null;
        v3_listademesh = null;

        isPlaying = false;
        editionMode = false;
        timer = 0;
        basemesh = null;

        timeline = null;

        keyframeCurrentTime = 0;
        keyframeDurationTime = 0;
        keyframeCurrent = 0;
        keyframeNew = 0;

        morphFrom = null;
        morphTo = null;

        settings = null;
    }
Exemplo n.º 15
0
    //***************************************************
    // Saving ...
    // **************************************************
    public static bool Save(string filename, List<SkinnedMeshRenderer> meshList, List<TagarelaTimelineUI.TLkeyframe> KeyframeSet, int MeshVertexCount, string AudioFile, float TotalTime)
    {
        // Where we want to save and load to and from
        _FileLocation = Application.dataPath + "/Tagarela/System/Animations/";
        _FileName = filename + ".xml";

        // we need soemthing to store the information into
        FileData = new TagarelaFileStructure();

        FileData.animationTime = TotalTime;
        FileData.audioFile = AudioFile;
        FileData.meshVertexCount = MeshVertexCount;

        string[] tempSaveData_Id = new string[meshList.Count];
        string[] tempSaveData_Description = new string[meshList.Count];
        for (int i = 0; i < meshList.Count; i++)
        {
            tempSaveData_Id[i] = meshList[i].name;
            tempSaveData_Description[i] = meshList[i].name;
        }
        FileData.meshList.id = tempSaveData_Id;
        FileData.meshList.description = tempSaveData_Description;

        FileData.keyframes.sliderSettings = new List<float[]>();
        FileData.keyframes.values = new float[KeyframeSet.Count];
        for (int i = 0; i < KeyframeSet.Count; i++)
        {
            //UI_TimeLine.TLkeyframe temp_keyframe = (UI_TimeLine.TLkeyframe);
            FileData.keyframes.sliderSettings.Add(KeyframeSet[i].morphSliders.sliderValue.ToArray());
            FileData.keyframes.values[i] = KeyframeSet[i].value;
            //FileData.keyframes.values[i] = (temp_keyframe.Value);
        }

        //FileData.Keyframes._single_keyframe =

        // Time to creat our XML!
        _data = SerializeObject(FileData);
        // This is the final resulting XML from the serialization process
        return CreateXML();
    }
Exemplo n.º 16
0
    //***************************************************
    // Saving ...
    // **************************************************
    public static TagarelaFileStructure UpdateSettings(List<SkinnedMeshRenderer> meshList, List<TagarelaTimelineUI.TLkeyframe> KeyframeSet, int MeshVertexCount, string AudioFile, float TotalTime)
    {
        // we need soemthing to store the information into
        FileData = new TagarelaFileStructure();

        FileData.animationTime = TotalTime;
        FileData.audioFile = AudioFile;
        FileData.meshVertexCount = MeshVertexCount;

        string[] tempSaveData_Id = new string[meshList.Count];
        string[] tempSaveData_Description = new string[meshList.Count];
        for (int i = 0; i < meshList.Count; i++)
        {
            tempSaveData_Id[i] = meshList[i].name;
            tempSaveData_Description[i] = meshList[i].name;
        }
        FileData.meshList.id = tempSaveData_Id;
        FileData.meshList.description = tempSaveData_Description;

        FileData.keyframes.sliderSettings = new List<float[]>();
        FileData.keyframes.values = new float[KeyframeSet.Count];
        for (int i = 0; i < KeyframeSet.Count; i++)
        {
            //UI_TimeLine.TLkeyframe temp_keyframe = (UI_TimeLine.TLkeyframe);
            FileData.keyframes.sliderSettings.Add(KeyframeSet[i].morphSliders.sliderValue.ToArray());
            FileData.keyframes.values[i] = KeyframeSet[i].value;
            //FileData.keyframes.values[i] = (temp_keyframe.Value);
        }

        return FileData;
    }
Exemplo n.º 17
0
 public void OpenFile(TextAsset file)
 {
     Tagarela_loader LoadFile = new Tagarela_loader();
     settings = LoadFile.Load(file);
     audio.clip = null;
     audio.clip = audioFiles.Find(delegate(AudioClip a) { return a.name == settings.audioFile; });
 }
Exemplo n.º 18
0
    public override void OnInspectorGUI()
    {
        if (setStyles)
        {
            styleBoxStep         = new GUIStyle(GUI.skin.window);
            styleBoxStep.margin  = new RectOffset(6, 6, 0, 0);
            styleBoxStep.padding = new RectOffset(4, 4, 1, 4);

            styleBoxStepTitle          = new GUIStyle(EditorStyles.boldLabel);
            styleBoxStepTitle.margin   = new RectOffset(0, 0, 0, 0);
            styleBoxStepTitle.padding  = new RectOffset(0, 0, 1, 0);
            styleBoxStepTitle.wordWrap = true;

            styleBoxStepContent          = new GUIStyle(EditorStyles.wordWrappedLabel);
            styleBoxStepContent.margin   = new RectOffset(0, 0, 4, 0);
            styleBoxStepContent.padding  = new RectOffset(0, 0, 0, 0);
            styleBoxStepContent.wordWrap = true;

            styleBoxError        = new GUIStyle(styleBoxStep);
            styleBoxErrorTitle   = new GUIStyle(styleBoxStepTitle);
            styleBoxErrorContent = new GUIStyle(styleBoxStepContent);

            styleBoxErrorTitle = new GUIStyle();
            styleBoxErrorTitle.normal.textColor   = Color.white;
            styleBoxErrorContent.normal.textColor = Color.white;

            styleLabelGrid = new GUIStyle();
            styleLabelGrid.normal.background = EditorStyles.toolbarTextField.normal.background;
            styleLabelGrid.normal.textColor  = EditorStyles.toolbarTextField.normal.textColor;
            styleLabelGrid.fontStyle         = EditorStyles.toolbarTextField.fontStyle;
            styleLabelGrid.margin            = new RectOffset(0, 0, 0, 0);
            styleLabelGrid.border            = new RectOffset(2, 2, 3, 3);
            styleLabelGrid.padding           = new RectOffset(2, 2, 1, 2);

            styleButtonGrid               = new GUIStyle();
            styleButtonGrid               = EditorStyles.miniButtonRight;
            styleButtonGrid.margin.top    = 0;
            styleButtonGrid.padding.top   = 0;
            styleButtonGrid.padding.left  = 0;
            styleButtonGrid.margin.right  = 0;
            styleButtonGrid.margin.bottom = 2;

            styleGrid        = new GUIStyle();
            styleGrid.margin = new RectOffset(6, 4, 2, 2);

            styleMiniLabel           = new GUIStyle(EditorStyles.miniLabel);
            styleMiniLabel.alignment = TextAnchor.MiddleCenter;

            setStyles = false;
        }

        GUI.color = Color.white;

        GUILayout.Space(0);
        Rect lastRect = GUILayoutUtility.GetLastRect();

        GUI.DrawTexture(new Rect(0, lastRect.y + 4, Screen.width, bg_inspector.height), bg_inspector);

        GUILayout.Space(10);

        EditorGUILayout.BeginHorizontal();
        {
            GUILayout.Box(new GUIContent(logo_inspector), new GUIStyle(), new GUILayoutOption[] { GUILayout.Width(110), GUILayout.Height(35) });
            if (nextStepBox != 0 || messageError != "")
            {
                GUI.enabled = false;
                GUI.color   = Color.black;
            }

            if (GUILayout.Button("Open Editor", new GUILayoutOption[] { GUILayout.Height(22) }))
            {
                TagarelaEditor.GetWindow(typeof(TagarelaEditor)).Show();
            }
        }
        EditorGUILayout.EndHorizontal();
        GUI.color   = Color.white;
        GUI.enabled = true;
        EditorGUILayout.BeginVertical();
        {
            GUILayout.Space(4);
            GUI.enabled = true;

            nextStep     = true;
            nextStepBox  = 0;
            messageError = "";

            tagarela.FindBlendShapes();

            if (nextStepBox != 1)
            {
                EditorGUILayout.Separator();
                toolbar     = GUILayout.Toolbar(toolbar, toolbarContent);
                GUI.enabled = true;

                switch (toolbar)
                {
                case 0:     //Audio

                    EditorGUILayout.Separator();

                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Audio Clip:");
                        tempAudio = EditorGUILayout.ObjectField(tempAudio, typeof(AudioClip), false) as AudioClip;
                        if (tempAudio == null)
                        {
                            GUI.enabled = false;
                        }
                        if (GUILayout.Button("Add", new GUILayoutOption[] { GUILayout.Width(60), GUILayout.Height(16) }) && !tagarela.audioFiles.Find(delegate(AudioClip a)
                        {
                            return(a.name == tempAudio.name);
                        }))
                        {
                            tagarela.audioFiles.Add(tempAudio);
                            tempAudio = null;
                        }
                        GUI.enabled = true;
                    }
                    EditorGUILayout.EndHorizontal();


                    if (tagarela.audioFiles.Count > 0)
                    {
                        EditorGUILayout.BeginVertical(styleGrid);
                        {
                            tagarela.audioFiles.ForEach(delegate(AudioClip a)
                            {
                                EditorGUILayout.BeginHorizontal();

                                GUILayout.Box(a.name, styleLabelGrid, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(16) });
                                if (GUILayout.Button("Remove", styleButtonGrid, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(16), GUILayout.Width(59) }))
                                {
                                    //if (GUILayout.Button("X ", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Height(20), GUILayout.Width(20) }))
                                    tagarela.audioFiles.Remove(a);
                                    tempAudio = null;
                                }

                                EditorGUILayout.EndHorizontal();
                            });
                        }
                        EditorGUILayout.EndVertical();
                    }
                    tempLipFilePreview = null;
                    break;

                case 1:     //lip files

                    EditorGUILayout.Separator();

                    //tempLipFile = EditorGUILayout.ObjectField("Lip Sync files", tempLipFile, typeof(TextAsset), false) as TextAsset;
                    if (GUILayout.Button("Add Animation from Assets"))
                    {
                        string path = EditorUtility.OpenFilePanel("Tagarela Animation Files", Application.dataPath + "/Tagarela/Animations/", "xml");
                        path        = path.Replace(Application.dataPath, "Assets");
                        tempLipFile = AssetDatabase.LoadMainAssetAtPath(path) as TextAsset;
                        if (tempLipFile != null)
                        {
                            tempLipFilePreview = TagarelaFileManager.Load(tempLipFile);
                            if (tempLipFilePreview.meshVertexCount == vertexCount)
                            {
                                if (tagarela.animationFiles.Find(delegate(TextAsset a)
                                {
                                    return(a.name == tempLipFile.name);
                                }) == null)
                                {
                                    tagarela.animationFiles.Add(tempLipFile);
                                    tempLipFile = null;
                                }
                                ;
                            }
                        }
                    }

                    if (tempLipFilePreview != null && tempLipFilePreview.meshVertexCount != vertexCount)
                    {
                        EditorGUILayout.Separator();
                        GUIErrorBox("The selected file has inconsistent data.");
                        EditorGUILayout.Separator();
                    }

                    if (tagarela.animationFiles.Count > 0)
                    {
                        EditorGUILayout.BeginVertical(styleGrid);
                        {
                            //int index = 0;

                            for (int index = tagarela.animationFiles.Count - 1; index >= 0; index--)
                            {
                                EditorGUILayout.BeginHorizontal();
                                TextAsset f = tagarela.animationFiles[index];
                                GUILayout.Box("(" + index + ") " + f.name, styleLabelGrid, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(16) });

                                if (GUILayout.Button("Remove", styleButtonGrid, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(16), GUILayout.Width(59) }))
                                {
                                    switch (EditorUtility.DisplayDialogComplex("Remove", "Do you want to delete completely the file?", "Yes", "No, Just remove", "Cancel"))
                                    {
                                    case 0:
                                        tagarela.animationFiles.Remove(f);
                                        TagarelaFileManager.Delete(f);
                                        tempLipFile = null;
                                        Repaint();
                                        break;

                                    case 1:
                                        tagarela.animationFiles.Remove(f);
                                        tempLipFile = null;
                                        break;
                                    }
                                }

                                EditorGUILayout.EndHorizontal();
                            }
                        }
                        EditorGUILayout.EndVertical();
                    }

                    break;
                }
            }

            GUI.enabled = true;

            if (!nextStep && messageError != "")
            {
                GUIErrorBox(messageError);
            }

            EditorGUILayout.Separator();

            switch (nextStepBox)
            {
            case 1:
                GUInextStepBox("Step 1 - Main Object", "Select in Scene or Hierarchy Window the Main Object that you want to control. This object must have a Mesh Renderer or Skinned Mesh Renderer Component. In some cases, this is the Main Object.");
                EditorGUILayout.Separator();
                break;

            case 2:
                GUInextStepBox("Step 2 - Neutral Mesh", "Select a Neutral Mesh in your Project Window.");
                EditorGUILayout.Separator();
                break;

            case 3:
                GUInextStepBox("Step 3 - Blend Shapes", "Select at least one Blend Shape in your Project Window and click in Add.");
                EditorGUILayout.Separator();
                break;
            }

            GUILayout.Label(versionNumber, styleMiniLabel, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(16) });
            GUILayout.Label("Developed by Rodrigo Pegorari - 2014\nhttp://www.rodrigopegorari.net", styleMiniLabel, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(26) });
            GUILayout.Space(4f);
        }
        EditorGUILayout.EndVertical();
    }
Exemplo n.º 19
0
    public void CleanVars()
    {
        RestoreOriginalMesh();

        if (tagarela.mainObject.GetComponent<MeshFilter>())
        {
            tagarela.mainObject.GetComponent<MeshFilter>().sharedMesh.vertices = tagarela.neutralMesh.vertices;
        }
        else if (tagarela.mainObject.GetComponent<SkinnedMeshRenderer>())
        {
            tagarela.mainObject.GetComponent<SkinnedMeshRenderer>().sharedMesh.vertices = tagarela.neutralMesh.vertices;
        }

        updateMorph = false;
        tagarela.audio.clip = null;
        lastSelectionGameObjectEditing = null;
        log_msg = "";
        fileName = "";
        settings = null;
    }
Exemplo n.º 20
0
    public override void OnInspectorGUI()
    {
        if (setStyles)
        {
            styleBoxStep = new GUIStyle(GUI.skin.window);
            styleBoxStep.margin = new RectOffset(6, 6, 0, 0);
            styleBoxStep.padding = new RectOffset(4, 4, 1, 4);

            styleBoxStepTitle = new GUIStyle(EditorStyles.boldLabel);
            styleBoxStepTitle.margin = new RectOffset(0, 0, 0, 0);
            styleBoxStepTitle.padding = new RectOffset(0, 0, 1, 0);
            styleBoxStepTitle.wordWrap = true;

            styleBoxStepContent = new GUIStyle(EditorStyles.wordWrappedLabel);
            styleBoxStepContent.margin = new RectOffset(0, 0, 4, 0);
            styleBoxStepContent.padding = new RectOffset(0, 0, 0, 0);
            styleBoxStepContent.wordWrap = true;

            styleBoxError = new GUIStyle(styleBoxStep);
            styleBoxErrorTitle = new GUIStyle(styleBoxStepTitle);
            styleBoxErrorContent = new GUIStyle(styleBoxStepContent);

            styleBoxErrorTitle = new GUIStyle();
            styleBoxErrorTitle.normal.textColor = Color.white;
            styleBoxErrorContent.normal.textColor = Color.white;

            styleLabelGrid = new GUIStyle();
            styleLabelGrid.normal.background = EditorStyles.toolbarTextField.normal.background;
            styleLabelGrid.normal.textColor = EditorStyles.toolbarTextField.normal.textColor;
            styleLabelGrid.fontStyle = EditorStyles.toolbarTextField.fontStyle;
            styleLabelGrid.margin = new RectOffset(0, 0, 0, 0);
            styleLabelGrid.border = new RectOffset(2, 2, 3, 3);
            styleLabelGrid.padding = new RectOffset(2, 2, 1, 2);

            styleButtonGrid = new GUIStyle();
            styleButtonGrid = EditorStyles.miniButtonRight;
            styleButtonGrid.margin.top = 0;
            styleButtonGrid.padding.top = 0;
            styleButtonGrid.padding.left = 0;
            styleButtonGrid.margin.right = 0;
            styleButtonGrid.margin.bottom = 2;

            styleGrid = new GUIStyle();
            styleGrid.margin = new RectOffset(6, 4, 2, 2);

            styleMiniLabel = new GUIStyle(EditorStyles.miniLabel);
            styleMiniLabel.alignment = TextAnchor.MiddleCenter;

            setStyles = false;
        }

        GUI.color = Color.white;

        GUILayout.Space(0);
        Rect lastRect = GUILayoutUtility.GetLastRect();
        GUI.DrawTexture(new Rect(0, lastRect.y + 4, Screen.width, bg_inspector.height), bg_inspector);

        GUILayout.Space(10);

        EditorGUILayout.BeginHorizontal();
        {
            GUILayout.Box(new GUIContent(logo_inspector), new GUIStyle(), new GUILayoutOption[] { GUILayout.Width(110), GUILayout.Height(35) });
            if (nextStepBox != 0 || messageError != "")
            {
                GUI.enabled = false;
                GUI.color = Color.black;
            }

            if (GUILayout.Button("Open Editor", new GUILayoutOption[] { GUILayout.Height(22) }))
            {
                TagarelaEditor.GetWindow(typeof(TagarelaEditor)).Show();
            }

        }
        EditorGUILayout.EndHorizontal();
        GUI.color = Color.white;
        GUI.enabled = true;
        EditorGUILayout.BeginVertical();
        {
            GUILayout.Space(4);
            GUI.enabled = true;

            nextStep = true;
            nextStepBox = 0;
            messageError = "";

            tagarela.FindBlendShapes();

            if (nextStepBox != 1)
            {
                EditorGUILayout.Separator();
                toolbar = GUILayout.Toolbar(toolbar, toolbarContent);
                GUI.enabled = true;

                switch (toolbar)
                {

                    case 0: //Audio

                        EditorGUILayout.Separator();

                        EditorGUILayout.BeginHorizontal();
                        {
                            GUILayout.Label("Audio Clip:");
                            tempAudio = EditorGUILayout.ObjectField(tempAudio, typeof(AudioClip), false) as AudioClip;
                            if (tempAudio == null)
                                GUI.enabled = false;
                            if (GUILayout.Button("Add", new GUILayoutOption[] { GUILayout.Width(60), GUILayout.Height(16) }) && !tagarela.audioFiles.Find(delegate(AudioClip a)
                            {
                                return a.name == tempAudio.name;
                            }))
                            {
                                tagarela.audioFiles.Add(tempAudio);
                                tempAudio = null;
                            }
                            GUI.enabled = true;
                        }
                        EditorGUILayout.EndHorizontal();

                        if (tagarela.audioFiles.Count > 0)
                        {
                            EditorGUILayout.BeginVertical(styleGrid);
                            {
                                tagarela.audioFiles.ForEach(delegate(AudioClip a)
                                {
                                    EditorGUILayout.BeginHorizontal();

                                    GUILayout.Box(a.name, styleLabelGrid, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(16) });
                                    if (GUILayout.Button("Remove", styleButtonGrid, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(16), GUILayout.Width(59) }))
                                    {
                                        //if (GUILayout.Button("X ", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Height(20), GUILayout.Width(20) }))
                                        tagarela.audioFiles.Remove(a);
                                        tempAudio = null;
                                    }

                                    EditorGUILayout.EndHorizontal();
                                });
                            }
                            EditorGUILayout.EndVertical();
                        }
                        tempLipFilePreview = null;
                        break;

                    case 1: //lip files

                        EditorGUILayout.Separator();

                        //tempLipFile = EditorGUILayout.ObjectField("Lip Sync files", tempLipFile, typeof(TextAsset), false) as TextAsset;
                        if (GUILayout.Button("Add Animation from Assets"))
                        {
                            string path = EditorUtility.OpenFilePanel("Tagarela Animation Files", Application.dataPath + "/Tagarela/Animations/", "xml");
                            path = path.Replace(Application.dataPath, "Assets");
                            tempLipFile = AssetDatabase.LoadMainAssetAtPath(path) as TextAsset;
                            if (tempLipFile != null)
                            {
                                tempLipFilePreview = TagarelaFileManager.Load(tempLipFile);
                                if (tempLipFilePreview.meshVertexCount == vertexCount)
                                {
                                    if (tagarela.animationFiles.Find(delegate(TextAsset a)
                                    {
                                        return a.name == tempLipFile.name;
                                    }) == null)
                                    {
                                        tagarela.animationFiles.Add(tempLipFile);
                                        tempLipFile = null;
                                    }
                                    ;
                                }
                            }

                        }

                        if (tempLipFilePreview != null && tempLipFilePreview.meshVertexCount != vertexCount)
                        {
                            EditorGUILayout.Separator();
                            GUIErrorBox("The selected file has inconsistent data.");
                            EditorGUILayout.Separator();
                        }

                        if (tagarela.animationFiles.Count > 0)
                        {
                            EditorGUILayout.BeginVertical(styleGrid);
                            {
                                //int index = 0;

                                for (int index = tagarela.animationFiles.Count - 1; index >= 0; index--)
                                {
                                    EditorGUILayout.BeginHorizontal();
                                    TextAsset f = tagarela.animationFiles[index];
                                    GUILayout.Box("(" + index + ") " + f.name, styleLabelGrid, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(16) });

                                    if (GUILayout.Button("Remove", styleButtonGrid, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(16), GUILayout.Width(59) }))
                                    {
                                        switch (EditorUtility.DisplayDialogComplex("Remove", "Do you want to delete completely the file?", "Yes", "No, Just remove", "Cancel"))
                                        {
                                            case 0:
                                                tagarela.animationFiles.Remove(f);
                                                TagarelaFileManager.Delete(f);
                                                tempLipFile = null;
                                                Repaint();
                                                break;
                                            case 1:
                                                tagarela.animationFiles.Remove(f);
                                                tempLipFile = null;
                                                break;
                                        }

                                    }

                                    EditorGUILayout.EndHorizontal();
                                }

                            }
                            EditorGUILayout.EndVertical();
                        }

                        break;
                }
            }

            GUI.enabled = true;

            if (!nextStep && messageError != "")
            {
                GUIErrorBox(messageError);
            }

            EditorGUILayout.Separator();

            switch (nextStepBox)
            {
                case 1:
                    GUInextStepBox("Step 1 - Main Object", "Select in Scene or Hierarchy Window the Main Object that you want to control. This object must have a Mesh Renderer or Skinned Mesh Renderer Component. In some cases, this is the Main Object.");
                    EditorGUILayout.Separator();
                    break;

                case 2:
                    GUInextStepBox("Step 2 - Neutral Mesh", "Select a Neutral Mesh in your Project Window.");
                    EditorGUILayout.Separator();
                    break;

                case 3:
                    GUInextStepBox("Step 3 - Blend Shapes", "Select at least one Blend Shape in your Project Window and click in Add.");
                    EditorGUILayout.Separator();
                    break;
            }

            GUILayout.Label(versionNumber, styleMiniLabel, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(16) });
            GUILayout.Label("Developed by Rodrigo Pegorari - 2014\nhttp://www.rodrigopegorari.net", styleMiniLabel, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(26) });
            GUILayout.Space(4f);
        }
        EditorGUILayout.EndVertical();
    }
Exemplo n.º 21
0
    public void ChangeAnimLength(float newLength)
    {
        //Update the file settings

        guiTimeline.totalValue = newLength;

        List<TagarelaTimelineUI.TLkeyframe> keySet = new List<TagarelaTimelineUI.TLkeyframe>(guiTimeline.keyframeSet);

        keySet.RemoveAll(item => item.value > newLength);

        guiTimeline.keyframeSet = keySet;

        settings = TagarelaFileManager.UpdateSettings(tagarela.morphTargets, guiTimeline.keyframeSet, tagarela.neutralMesh.vertexCount, "", guiTimeline.totalValue);

        //guiTimeline.UpdateSelection();
        guiTimelineSegment.totalValue = newLength;
        guiTimelineSegment.KeyframeSet[0].Value = 0;
        guiTimelineSegment.KeyframeSet[1].Value = newLength;
        guiTimelineSegment.UpdateSelection();

        settings.animationTime = newLength;

        Repaint();
        tagarela.settings = settings;
        tagarela.BuildTimeline();
        updateTimeline = true;

        Repaint();
        Update();
        playMode = PlayMode.currentTime;
    }
Exemplo n.º 22
0
    public void Clean()
    {
        audio.clip = null;

        isPlaying = false;
        editionMode = false;
        timer = 0;

        timeline = null;

        keyframeCurrentTime = 0;
        keyframeDurationTime = 0;
        keyframeCurrent = 0;
        keyframeNew = 0;

        morphFrom = null;
        morphTo = null;

        settings = null;
    }