Esempio n. 1
0
 public bool AssetEquals(AssetIdentifierTuple other)
 {
     return(AssetId.IsValid(source) == AssetId.IsValid(other.source) &&
            source.AssetEquals(other.source) &&
            AssetId.IsValid(destination) == AssetId.IsValid(other.destination) &&
            destination.AssetEquals(other.destination));
 }
        void GetRemapSource(string directory)
        {
            if (string.IsNullOrEmpty(directory) || !Directory.Exists(directory))
            {
                Debug.LogWarning("No source directory selected.");
                return;
            }

            var remapObject = GetGuidRemapObject();

            string localDirectory = directory.Replace("\\", "/").Replace(Application.dataPath, "Assets") + "/";

            if (!remapObject.sourceDirectory.Contains(localDirectory))
            {
                remapObject.sourceDirectory.Add(localDirectory);
            }

            List <AssetIdentifierTuple> map = remapObject.map;

            foreach (var id in GetAssetIdentifiersInDirectory(localDirectory, k_DirectoryExcludeFilter))
            {
                id.SetPathRelativeTo(localDirectory);

                if (map.Any(x => x.source != null && x.source.Equals(id)))
                {
                    continue;
                }

                // the only time where a destination can exist with a null source is when a single destination is in the
                // map, so it's okay to grab the first and not bother searching for more dangling destination entries
                AssetIdentifierTuple matchingDestination =
                    map.FirstOrDefault(x =>
                {
                    return(x.destination != null &&
                           x.destination.AssetEquals(id));
                });

                if (matchingDestination != null)
                {
                    if (AssetId.IsValid(matchingDestination.source))
                    {
                        map.Add(new AssetIdentifierTuple(id, matchingDestination.destination));
                    }
                    else
                    {
                        matchingDestination.source = id;
                    }
                }
                else
                {
                    map.Add(new AssetIdentifierTuple(id, null));
                }
            }

            m_TreeView.isDirty = true;
        }