Exemplo n.º 1
0
        public static void ApplyFormatToObject(AnimationImportData data)
        {
            if (data == null)
            {
                return;
            }

            List <object> unFortmatObject = data.GetObjects(true);

            for (int i = 0; i < unFortmatObject.Count; ++i)
            {
                AnimationInfo texInfo = unFortmatObject[i] as AnimationInfo;
                string        name    = System.IO.Path.GetFileName(texInfo.Path);
                if (EditorUtility.DisplayCancelableProgressBar("设置动作格式", name, (i * 1.0f) / unFortmatObject.Count))
                {
                    Debug.LogWarning("[AnimationFormater]ApplyFormatToObject Stop.");
                    break;
                }
                if (texInfo == null)
                {
                    continue;
                }
                ModelImporter tImporter = AssetImporter.GetAtPath(texInfo.Path) as ModelImporter;
                if (tImporter == null)
                {
                    continue;
                }

                bool needImport = false;

                if (data.AnimationType != tImporter.animationType)
                {
                    tImporter.animationType = data.AnimationType;
                    needImport = true;
                }

                if (data.AnimationCompression != tImporter.animationCompression)
                {
                    tImporter.animationCompression = data.AnimationCompression;
                    needImport = true;
                }

                if (needImport)
                {
                    tImporter.SaveAndReimport();
                }
            }
            EditorUtility.ClearProgressBar();

            for (int i = 0; i < unFortmatObject.Count; ++i)
            {
                AnimationInfo texInfo = unFortmatObject[i] as AnimationInfo;
                string        name    = System.IO.Path.GetFileName(texInfo.Path);
                EditorUtility.DisplayProgressBar("更新动作数据", name, (i * 1.0f) / unFortmatObject.Count);
                AnimationInfo.CreateAnimationInfo(texInfo.Path);
            }
            EditorUtility.ClearProgressBar();
        }
Exemplo n.º 2
0
        public override void CopyData(ImportData data)
        {
            AnimationImportData tData = data as AnimationImportData;

            if (tData == null)
            {
                return;
            }

            base.CopyData(data);
            AnimationType        = tData.AnimationType;
            AnimationCompression = tData.AnimationCompression;
        }
Exemplo n.º 3
0
        public override void Draw(Rect r)
        {
            int   border        = TableConst.TableBorder;
            float split         = TableConst.SplitterRatio;
            int   toolbarHeight = 80;

            GUILayout.BeginArea(r);
            GUILayout.BeginVertical();

            m_control.Draw();

            AnimationImportData data = m_control.Data;

            GUILayout.BeginHorizontal(TableStyles.Toolbar);
            {
                GUILayout.Label("AnimationType: ", GUILayout.Width(120));
                int aniType = GUILayout.SelectionGrid((int)data.AnimationType,
                                                      TableConst.AnimationType, TableConst.AnimationType.Length, TableStyles.ToolbarButton);
                if (aniType != (int)data.AnimationType)
                {
                    data.AnimationType = (ModelImporterAnimationType)aniType;
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal(TableStyles.Toolbar);
            {
                GUILayout.Label("AnimationType: ", GUILayout.Width(120));
                int aniCompression = GUILayout.SelectionGrid((int)data.AnimationCompression,
                                                             TableConst.AnimationCompression, TableConst.AnimationCompression.Length, TableStyles.ToolbarButton);
                if (aniCompression != (int)data.AnimationCompression)
                {
                    data.AnimationCompression = (ModelImporterAnimationCompression)aniCompression;
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal(TableStyles.Toolbar);
            {
                bool showUnFormatObject = GUILayout.Toggle(m_control.UnFormat, " Show Unformat Data");
                if (showUnFormatObject != m_control.UnFormat)
                {
                    m_control.UnFormat = showUnFormatObject;
                    m_control.OnDataSelectedIndex();
                }

                if (GUILayout.Button("Move Up Priority", TableStyles.ToolbarButton, GUILayout.MaxWidth(120)))
                {
                    m_control.ModifDataPriority(true);
                }

                if (GUILayout.Button("Move Down Priority", TableStyles.ToolbarButton, GUILayout.MaxWidth(120)))
                {
                    m_control.ModifDataPriority(false);
                }

                if (GUILayout.Button("Apply Select Format", TableStyles.ToolbarButton, GUILayout.MaxWidth(160)))
                {
                    AnimationFormater.ApplyFormatToObject(m_control.SelectData);
                }

                if (GUILayout.Button("Refresh Select Data", TableStyles.ToolbarButton, GUILayout.MaxWidth(140)))
                {
                    if (m_control.Index != -1)
                    {
                        m_control.RefreshDataByRootPath(m_control.SelectData.RootPath);
                    }
                }

                if (GUILayout.Button("Refresh All Data", TableStyles.ToolbarButton, GUILayout.MaxWidth(140)))
                {
                    m_control.RefreshBaseData();
                }

                GUILayout.FlexibleSpace();
            }
            GUILayout.EndHorizontal();

            int startY = toolbarHeight + border;
            int height = (int)(r.height - startY - border * 2);

            if (m_dataTable != null)
            {
                m_dataTable.Draw(new Rect(border, startY, r.width - 2 * border, (int)(height * split - border * 1.5f)));
            }

            if (m_showTable != null)
            {
                m_showTable.Draw(new Rect(border, (int)(height * split + border * 0.5f + startY), r.width - 2 * border, (int)(height * (1.0f - split) - border * 1.5f)));
            }

            GUILayout.EndVertical();
            GUILayout.EndArea();
        }