Exemplo n.º 1
0
 bool typeMatches(Type b)
 {
     if (matchChildClasses)
     {
         return(type.IsAssignableFrom(b));
     }
     else
     {
         if (searchValue.isDirectory)
         {
             ClassSearchInfo csi = null;
             if (typeHash.TryGetValue(b, out csi))
             {
                 csi.numFound++;
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             return(type == b);
         }
     }
 }
Exemplo n.º 2
0
 public override void OnSearchEnd(SearchJob job, SearchItem item)
 {
     if (showUnusedScripts)
     {
         foreach (var kvp in typeHash)
         {
             ClassSearchInfo csi = kvp.Value;
             if (csi.numFound == 0)
             {
                 SearchResult result = new SearchResult();
                 result.pathInfo    = PathInfo.GetPathInfo(csi.script, job);
                 result.actionTaken = SearchAction.NotFound;
                 result.strRep      = kvp.Key.ToString();
                 job.MatchFound(result, item);
             }
         }
     }
 }
Exemplo n.º 3
0
        void initializeTypeHash()
        {
            typeHash = new Dictionary <Type, ClassSearchInfo>();
            string[]             assetPaths    = AssetDatabase.GetAllAssetPaths();
            IEnumerable <string> filteredPaths = assetPaths.Where(asset => suffixes.Any(suffix => asset.EndsWith(suffix, System.StringComparison.OrdinalIgnoreCase)));
            string scopePath = searchValue.assetPath;

            filteredPaths = filteredPaths.Where(asset => asset.StartsWith(scopePath)).ToArray();

            foreach (string path in filteredPaths)
            {
                MonoScript ms = (MonoScript)AssetDatabase.LoadAssetAtPath(path, typeof(MonoScript));

                Type t = ms.GetClass();

                if (typeof(ScriptableObject).IsAssignableFrom(t) || typeof(MonoBehaviour).IsAssignableFrom(t))
                {
                    typeHash[t] = new ClassSearchInfo(ms);
                }
            }
        }