Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 1.16 KB

File metadata and controls

29 lines (22 loc) · 1.16 KB

UnityPrefabTester

Alt text

Ultimate prefab property tester for nested prefab era. This is editor script to demonstrate ALL* prefab related API in Unity Editor. *(Except prefab variant related)

It will test/distinguish selected game object if it is "part of" or "root of" any prefab type. Including

  • Prefab Asset (The one that sits in Asset folder)
  • Prefab Instance (The one that dragged into scene)
  • Prefab Stage (Editing prefab intermediate in UnityEditor prefab edit mode)

Including resolve nearest asset path, root of prefab if available.

To try the example API, import package or open demo project. Select menu Tool->Prefab tester API example

Related API used:

  • PrefabUtility.IsPartOfPrefabAsset
  • PrefabUtility.GetNearestPrefabInstanceRoot
  • PrefabStageUtility.GetCurrentPrefabStage
  • PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot
  • AssetDatabase.GetAssetPath

Possible useful scenario:

  • Useful for some editor script automation based on prefabs.
  • Originally, I write this code to fix Mirror network plugin issue on determining assetPath on NetworkIdentity in complex cases which my game is using.