Пример #1
0
        public static void Split()
        {
            UnityEngine.Object _activeObject = Selection.activeObject;
            if (_activeObject.GetType() == typeof(SkeletonDataAsset))
            {
                string _path = AssetDatabase.GetAssetPath(_activeObject);

                SpineXiimoonConfig _config = AssetDatabase.LoadAssetAtPath(configPath, typeof(SpineXiimoonConfig)) as SpineXiimoonConfig;
                if (_config == null)
                {
                    return;
                }

                string exportPath = GetAnimationExportPath(_path, _config);
                if (string.IsNullOrEmpty(exportPath))
                {
                    return;
                }
                _config = null;

                SplitAnimationTool.DoSplit(_path, exportPath, 0);
            }
        }
Пример #2
0
        void OnGUI()
        {
            scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Height(600));
            GUILayout.Space(10);

            GUILayout.Label("操作的路径:");
            for (int i = 0; i < _config.dopaths.Count; i++)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("操作路径:" + (i + 1) + "    " + _config.dopaths[i] + " >>> 动画导出到 >>> " + GetPathExportPath(_config.dopaths[i]));
                if (GUILayout.Button("Remove"))
                {
                    _config.dopaths.RemoveAt(i);
                    EditorUtility.SetDirty(_config);
                    AssetDatabase.SaveAssets();
                }
                GUILayout.EndHorizontal();
            }

            if (GUILayout.Button("添加目录"))
            {
                string _selectPath = EditorUtility.OpenFolderPanel("选择要添加的目录", "Assets/NScene/imported", string.Empty);
                if (!string.IsNullOrEmpty(_selectPath))
                {
                    _selectPath = "Assets" + _selectPath.Replace(Application.dataPath, "");
                    if (!_config.dopaths.Contains(_selectPath))
                    {
                        _config.dopaths.Add(_selectPath);
                        EditorUtility.SetDirty(_config);
                        AssetDatabase.SaveAssets();
                    }
                }
            }

            if (GUILayout.Button("拆分"))
            {
                assetPaths = new List <string>();
                for (int i = 0; i < _config.dopaths.Count; i++)
                {
                    DirectoryInfo dire = new DirectoryInfo(_config.dopaths[i]);
                    CollectSkeletonDataAssets(dire);
                }
                int totalCount = assetPaths.Count;
                for (int i = 0; i < totalCount; i++)
                {
                    try
                    {
                        SplitAnimationTool.DoSplit(assetPaths[i], GetAnimationExportPath(assetPaths[i], _config), _config.needSplitCount);
                        EditorUtility.DisplayProgressBar(string.Format("拆分动画中... {0}/{1}", i, totalCount), string.Format("{0}", Path.GetFileName(assetPaths[i])), (float)i / (float)totalCount);
                    }
                    catch (System.Exception e)
                    {
                        Debug.LogErrorFormat(AssetDatabase.LoadAssetAtPath <Object>(assetPaths[i]), e.ToString());
                    }
                }

                EditorUtility.ClearProgressBar();
            }

            // if (GUILayout.Button("从备份拆分"))
            // {
            //     assetPaths = new List<string>();
            //     for (int i = 0; i < _config.dopaths.Count; i++)
            //     {
            //         DirectoryInfo dire = new DirectoryInfo(_config.dopaths[i]);
            //         CollectSkeletonDataAssets(dire);
            //     }
            //     for (int i = 0; i < assetPaths.Count; i++)
            //     {
            //         SplitAnimationTool.DoSplit(assetPaths[i], GetAnimationExportPath(assetPaths[i], _config), _config.needSplitCount,true);
            //     }
            // }

            // GUILayout.Label("AssetPaths");
            // for (int i = 0; i < assetPaths.Count; i++)
            // {
            //     GUILayout.Label(i + " : " + assetPaths[i] + "   >>>  " + GetAnimationExportPath(assetPaths[i], _config));
            // }


            GUILayout.EndScrollView();
        }