Esempio n. 1
0
        void RemoveReference()
        {
            if (string.IsNullOrEmpty(focusedObjectPath))
            {
                return;
            }
            var guid = AssetDatabase.AssetPathToGUID(focusedObjectPath);
            var refs = GetOrNull(references, focusedObjectPath);

            foreach (var path in refs)
            {
                AssetDuplicator.RemoveGUID(path, guid);
            }
            prevTargets = null;
        }
Esempio n. 2
0
        void OnObjectListAssetDrop(string path, UnityObject o)
        {
            var destPath = AssetDatabase.GetAssetPath(o);

            if (Path.GetExtension(path) != Path.GetExtension(path))
            {
                Debug.LogErrorFormat("extension unmatch");
                return;
            }
            var before = AssetDatabase.AssetPathToGUID(path);
            var after  = AssetDatabase.AssetPathToGUID(destPath);

            AssetDuplicator.ReplaceDependencyGUIDs(Targets.Select(AssetDatabase.GetAssetPath), before, after);
            prevTargets.Clear();
        }
Esempio n. 3
0
 public static void RemoveGUID(string path, string guid)
 {
     AssetDuplicator.ProcessYAML(path, source =>
     {
         while (true)
         {
             var i = source.IndexOf(guid);
             if (i == -1)
             {
                 break;
             }
             var left  = source.LastIndexOf("{", i);
             var right = source.IndexOf("}", i);
             if (left == -1 || right == -1)
             {
                 break;
             }
             source = source.Substring(0, left) + "{fileID: 0}" + source.Substring(right + 1);
         }
         return(source);
     });
 }
Esempio n. 4
0
        void Duplicate()
        {
            var targetPaths = Targets.Select(o => AssetDatabase.GetAssetPath(o));

            AssetDuplicator.Duplicate(targetPaths, path => checks.ContainsKey(path) && checks[path]);
        }