Пример #1
0
 private void DoMoveAssets()
 {
     foreach (var kvp in moveAssetObjects)
     {
         moveAssetObjects.Remove(kvp.Key);
         break;
     }
     foreach (var kvp in moveAssetObjects)
     {
         AssetsUtility.MoveAssets(kvp.Key, kvp.Value.ToArray());
         break;
     }
     if (moveAssetObjects.Count <= 0)
     {
         AssetsUtility.OnMoveAssetsCompleted -= DoMoveAssets;
         AssetsUtility.OnMoveAssetsCanceled  -= DoMoveAssets;
         CancelMoveAssets();
     }
 }
Пример #2
0
        private void OnControlMatchedAssetsGUI()
        {
            string movePathKey;

            System.Type type, lastType = null;
            foreach (var assetObject in matchedAssets)
            {
                type = assetObject.GetType();
                if (lastType != null && type != lastType)
                {
                    EditorGUILayout.Space();
                    EditorGUILayout.Space();
                }
                if (lastType == null || type != lastType)
                {
                    movePathKey = MovePathKey + type.Name;
                    if (!movePaths.ContainsKey(movePathKey))
                    {
                        if (EditorPrefs.HasKey(movePathKey))
                        {
                            movePaths.Add(movePathKey, EditorPrefs.GetString(movePathKey));
                        }
                        else
                        {
                            movePaths.Add(movePathKey, Application.dataPath);
                        }
                    }
                    EditorGUILayout.LabelField(string.Format(MovePathStr, type.Name));
                    EditorGUILayout.BeginHorizontal();
                    movePaths[movePathKey] = EditorGUILayout.TextField(movePaths[movePathKey]);
                    if (GUILayout.Button(FolderStr, GUILayout.MaxWidth(50)))
                    {
                        var path = EditorUtility.OpenFolderPanel(string.Format(MovePathStr, type.Name), movePaths[movePathKey], EmptyStr);
                        if (!string.IsNullOrEmpty(path))
                        {
                            movePaths[movePathKey] = path;
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
                else
                {
                    EditorGUILayout.LabelField(EmptyStr);
                }
                lastType = type;
            }

            if (GUILayout.Button(StartMoveStr))
            {
                moveAssetObjects.Clear();

                foreach (var assetObject in matchedAssets)
                {
                    type        = assetObject.GetType();
                    movePathKey = MovePathKey + type.Name;

                    if (!moveAssetObjects.ContainsKey(movePaths[movePathKey]))
                    {
                        moveAssetObjects.Add(movePaths[movePathKey], new List <Object>());
                    }
                    moveAssetObjects[movePaths[movePathKey]].Add(assetObject);
                }

                AssetsUtility.OnMoveAssetsCompleted += DoMoveAssets;
                AssetsUtility.OnMoveAssetsCanceled  += DoMoveAssets;

                foreach (var kvp in moveAssetObjects)
                {
                    AssetsUtility.MoveAssets(kvp.Key, kvp.Value.ToArray());
                    break;
                }
            }
            if (GUILayout.Button(CancelMoveStr))
            {
                CancelMoveAssets();
            }
        }