예제 #1
0
    private void CheckUnConsistentSpriteInProject(AtlasProject project, out bool isAtlasConsistent, out List <SpriteConsistencyInfo> consistencyInfoTbl)
    {
        consistencyInfoTbl = new List <SpriteConsistencyInfo>();
        isAtlasConsistent  = true;

        if (null == project)
        {
            return;
        }

        List <string> spriteNameTblInProject = GetAllSpritePathInProject(project);
        List <string> spriteNameTblInPrefab  = GetAllSpriteNameInPrefab(project.DescribePath);

        //查找project
        foreach (var item in spriteNameTblInProject)
        {
            SpriteConsistencyInfo newConsistencyInfo = new SpriteConsistencyInfo();
            string spriteNameWithoutExt = Path.GetFileNameWithoutExtension(item);

            if (spriteNameTblInPrefab.Contains(spriteNameWithoutExt))
            {
                if (!File.Exists(@item))
                {
                    newConsistencyInfo.SpriteName      = spriteNameWithoutExt;
                    newConsistencyInfo.ProjectPath     = project.Path;
                    newConsistencyInfo.ExistInProject  = true;
                    newConsistencyInfo.ExistInPrefab   = true;
                    newConsistencyInfo.ExistInSourceAB = false;
                    newConsistencyInfo.IsConsistent    = false;

                    consistencyInfoTbl.Add(newConsistencyInfo);
                }

                //从prefab中移除该Sprite
                spriteNameTblInPrefab.Remove(spriteNameWithoutExt);
            }
            else
            {
                if (!File.Exists(item))
                {
                    newConsistencyInfo.ExistInSourceAB = false;
                }
                else
                {
                    newConsistencyInfo.ExistInSourceAB = true;
                }

                newConsistencyInfo.SpriteName     = spriteNameWithoutExt;
                newConsistencyInfo.ProjectPath    = project.Path;
                newConsistencyInfo.ExistInProject = true;
                newConsistencyInfo.ExistInPrefab  = false;
                newConsistencyInfo.IsConsistent   = false;

                consistencyInfoTbl.Add(newConsistencyInfo);
            }
        }

        //查找prefab
        if (spriteNameTblInPrefab.Count != 0)
        {
            List <string> sourcePicFilePath = UniversalEditorUtility.GetAllFileNameWithoutExtension(m_inputInfo.SourceSpriteDir);

            foreach (var item in spriteNameTblInPrefab)
            {
                SpriteConsistencyInfo newConsistencyInfo = new SpriteConsistencyInfo();
                if (!sourcePicFilePath.Contains(item))
                {
                    newConsistencyInfo.ExistInSourceAB = false;
                }
                else
                {
                    newConsistencyInfo.ExistInSourceAB = true;
                }

                newConsistencyInfo.SpriteName     = item;
                newConsistencyInfo.ProjectPath    = project.Path;
                newConsistencyInfo.ExistInProject = false;
                newConsistencyInfo.ExistInPrefab  = true;
                newConsistencyInfo.IsConsistent   = false;

                consistencyInfoTbl.Add(newConsistencyInfo);
            }
        }


        if (0 == consistencyInfoTbl.Count)
        {
            isAtlasConsistent = true;
        }
        else
        {
            isAtlasConsistent = false;
        }
    }