Skip to content

Commit

Permalink
Merge pull request #29 from Alan-Ben/master
Browse files Browse the repository at this point in the history
DontDestroyGameObject Can't be check , ui Mat without sprite can't be link GameObject
  • Loading branch information
HandCircus committed Jun 27, 2020
2 parents 0fc4268 + 57a5610 commit d5ab10f
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions ResourceChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1026,8 +1026,43 @@ private static GameObject[] GetAllRootGameObjects()
for (int sceneIdx = 0; sceneIdx < UnityEngine.SceneManagement.SceneManager.sceneCount; ++sceneIdx){
allGo.AddRange( UnityEngine.SceneManagement.SceneManager.GetSceneAt(sceneIdx).GetRootGameObjects().ToArray() );
}

allGo.AddRange(GetDontDestroyOnLoadRoots());
return allGo.ToArray();
#endif
}

private static List<GameObject> GetDontDestroyOnLoadRoots()
{
List<GameObject> objs = new List<GameObject>();
if (Application.isPlaying)
{
GameObject temp = null;
try
{
temp = new GameObject();
DontDestroyOnLoad(temp);
UnityEngine.SceneManagement.Scene dontDestryScene = temp.scene;
DestroyImmediate(temp);
temp = null;

if(dontDestryScene.IsValid())
{
objs = dontDestryScene.GetRootGameObjects().ToList();
}
}
catch (System.Exception e)
{
Debug.LogException(e);
return null;
}
finally
{
if(temp != null)
DestroyImmediate(temp);
}
}
return objs;
}

private T[] FindObjects<T>() where T : Object
Expand Down Expand Up @@ -1057,6 +1092,10 @@ private TextureDetails GetTextureDetail(Texture tTexture, Material tMaterial, Ma
{
if (!tTextureDetails.FoundInRenderers.Contains(renderer)) tTextureDetails.FoundInRenderers.Add(renderer);
}
foreach (Graphic graphic in tMaterialDetails.FoundInGraphics)
{
if (!tTextureDetails.FoundInGraphics.Contains(graphic)) tTextureDetails.FoundInGraphics.Add(graphic);
}
return tTextureDetails;
}

Expand Down

0 comments on commit d5ab10f

Please sign in to comment.