示例#1
0
    public static ClassFileDetails FindClassFile(string className)
    {
        ClassFileDetails details = DatabaseLink.GetClassFileDetails(className);

        if (details == null)
        {
            //Lookup class name in file names
            classFiles = new List <string>();
            FindAllScriptFiles(Application.dataPath);
            Debug.Log(classFiles.Count);
            for (int i = 0; i < classFiles.Count; i++)
            {
                if (classFiles[i].Contains(className))
                {
                    details = new ClassFileDetails(className, classFiles[i], File.GetLastAccessTimeUtc(classFiles[i]));
                }
            }
            //Lookup class name in the class file text
            if (details == null)
            {
                for (int i = 0; i < classFiles.Count; i++)
                {
                    string codeFile = File.ReadAllText(classFiles[i]);
                    if (codeFile.Contains("class " + className))
                    {
                        details = new ClassFileDetails(className, classFiles[i], File.GetLastAccessTimeUtc(classFiles[i]));
                    }
                }
            }
            if (details == null)
            {
                Debug.LogWarning("Failed to lookup class file for class " + className);
            }
            return(details);
        }
        else
        {
            return(details);
        }
    }