[Editor]How can I get components in non-instantiated prefab?

when i get components in non-instantiated prefab( in project-view),it always return null. Please help!

[MenuItem("Test/Test prefab")]
    static void Test1()
    {
        Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
        foreach (Object obj in selection)
        {
            Transform[] tans = ((GameObject)obj).GetComponentsInChildren<Transform>();
            foreach (Transform tf in tans)
              Debug.Log(tf);
         }
    }

GetComponentsInChildren only returns active objects. Use GetComponentsInChildren<Transform>(true) to also find inactive ones (which will include uninstantiated prefab components).

Also, I get a cast runtime error if there are non-GameObjects in your selection, so wrap your loop body in:

if(obj is GameObject){...}