void CheckReference()
        {
            foreach (var shader in shaderFileList)
            {
                var shaderFilePath = AssetDatabase.GUIDToAssetPath(shader.Value);
                if (File.Exists(shaderFilePath) == false)
                {
                    continue;
                }

                var guid = shader.Value;

                List <string>  referenceList = null;
                CollectionData reference     = null;

                if (references.Exists(c => c.fileGuid == guid) == false)
                {
                    referenceList = new List <string>();
                    reference     = new CollectionData()
                    {
                        fileGuid      = guid,
                        referenceGids = referenceList,
                    };
                    references.Add(reference);
                }
                else
                {
                    reference     = references.Find(c => c.fileGuid == guid);
                    referenceList = reference.referenceGids;
                }

                reference.timeStamp = File.GetLastWriteTime(AssetDatabase.GUIDToAssetPath(guid));

                var code = ClassReferenceCollection.StripComment(File.ReadAllText(shaderFilePath));

                foreach (var checkingShaderName in shaderFileList.Keys)
                {
                    if (checkingShaderName == shader.Key)
                    {
                        continue;
                    }

                    if (code.IndexOf(checkingShaderName) != -1 && shaderFileList.ContainsKey(checkingShaderName))
                    {
                        var fileGuid = shaderFileList [checkingShaderName];
                        if (referenceList.Contains(fileGuid) == false)
                        {
                            referenceList.Add(fileGuid);
                        }
                    }
                }
            }
        }
Example #2
0
        private void UnregistReferenceFromIgnoreList()
        {
            var codePaths = deleteFileList.Where(fileName => Path.GetExtension(fileName) == ".cs");

            foreach (var path in codePaths)
            {
                var code = ClassReferenceCollection.StripComment(File.ReadAllText(path));
                if (Regex.IsMatch(code, "static\\s*(partial)*\\s*class"))
                {
                    UnregistFromDelteList(AssetDatabase.AssetPathToGUID(path));
                }
            }
        }
Example #3
0
        void UnregistEditorCodes()
        {
            // Exclude objects that reference from Editor API
            var editorcodes = Directory.GetFiles("Assets", "*.*", SearchOption.AllDirectories)
                              .Where(fileName => Path.GetExtension(fileName) == ".cs")
                              .Where(item => Regex.IsMatch(item, "[\\/\\\\]Editor[\\/\\\\]") == true)
                              .ToArray();

            EditorUtility.DisplayProgressBar("checking", "check reference from editor codes", 0.8f);

            foreach (var path in editorcodes)
            {
                var code = ClassReferenceCollection.StripComment(File.ReadAllText(path));
                if (Regex.IsMatch(code, "(\\[MenuItem|AssetPostprocessor|EditorWindow)"))
                {
                    UnregistFromDelteList(AssetDatabase.AssetPathToGUID(path));
                    continue;
                }
            }
            foreach (var path in editorcodes)
            {
                var guid = AssetDatabase.AssetPathToGUID(path);

                if (referenceCollection.Exists(c => c.fileGuid == guid) == false)
                {
                    continue;
                }

                var referenceGuids = referenceCollection.First(c => c.fileGuid == guid).referenceGids;



                if (referenceGuids.Any(c => deleteFileList.Contains(c) == true) == false)
                {
                    UnregistFromDelteList(AssetDatabase.AssetPathToGUID(path));
                }
            }
        }