Created
October 17, 2020 13:30
-
-
Save idbrii/bfe069ab143274bc84efdce54dce5652 to your computer and use it in GitHub Desktop.
A Unity editor window to show you the prefab-ness of an object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// public domain | |
// Add to Scripts/Editor/PrefabDetector.cs | |
using System.Collections.Generic; | |
using System.Collections; | |
using System.Linq; | |
using System; | |
using UnityEditor.Experimental.SceneManagement; | |
using UnityEditor.SceneManagement; | |
using UnityEditor; | |
using UnityEngine; | |
using Debug = UnityEngine.Debug; | |
using Object = UnityEngine.Object; | |
namespace idbrii | |
{ | |
public class PrefabDetector : EditorWindow | |
{ | |
[MenuItem("Tools/PrefabDetector")] | |
static void ShowToolbar() | |
{ | |
EditorWindow.GetWindow<PrefabDetector>("PrefabDetector"); | |
} | |
private Vector2 scroll; | |
public void OnGUI() | |
{ | |
var go = Selection.activeGameObject; | |
if (go == null) | |
{ | |
EditorGUILayout.HelpBox("Select a gameobject to examine.", MessageType.Info); | |
return; | |
} | |
EditorGUIUtility.labelWidth = 300; | |
scroll = EditorGUILayout.BeginScrollView(scroll); | |
{ | |
EditorGUILayout.ObjectField("Selection", go, typeof(GameObject), allowSceneObjects: true); | |
EditorGUILayout.Space(); | |
EditorGUILayout.LabelField("PrefabStageUtility", EditorStyles.boldLabel); | |
var stage = PrefabStageUtility.GetCurrentPrefabStage(); | |
EditorGUILayout.LabelField("GetCurrentPrefabStage", stage != null ? "has stage" : "null"); | |
if (stage != null) | |
{ | |
EditorGUILayout.LabelField("IsPartOfPrefabContents", "" + stage.IsPartOfPrefabContents(go)); | |
} | |
EditorGUILayout.Space(); | |
EditorGUILayout.LabelField("PrefabUtility", EditorStyles.boldLabel); | |
EditorGUILayout.LabelField("IsAddedComponentOverride", "" + PrefabUtility.IsAddedComponentOverride(go)); | |
EditorGUILayout.LabelField("IsAddedGameObjectOverride", "" + PrefabUtility.IsAddedGameObjectOverride(go)); | |
EditorGUILayout.LabelField("IsAnyPrefabInstanceRoot", "" + PrefabUtility.IsAnyPrefabInstanceRoot(go)); | |
EditorGUILayout.LabelField("IsDisconnectedFromPrefabAsset", "" + PrefabUtility.IsDisconnectedFromPrefabAsset(go)); | |
EditorGUILayout.LabelField("IsOutermostPrefabInstanceRoot", "" + PrefabUtility.IsOutermostPrefabInstanceRoot(go)); | |
EditorGUILayout.LabelField("IsPartOfAnyPrefab", "" + PrefabUtility.IsPartOfAnyPrefab(go)); | |
EditorGUILayout.LabelField("IsPartOfImmutablePrefab", "" + PrefabUtility.IsPartOfImmutablePrefab(go)); | |
EditorGUILayout.LabelField("IsPartOfModelPrefab", "" + PrefabUtility.IsPartOfModelPrefab(go)); | |
EditorGUILayout.LabelField("IsPartOfNonAssetPrefabInstance", "" + PrefabUtility.IsPartOfNonAssetPrefabInstance(go)); | |
EditorGUILayout.LabelField("IsPartOfPrefabAsset", "" + PrefabUtility.IsPartOfPrefabAsset(go)); | |
EditorGUILayout.LabelField("IsPartOfPrefabInstance", "" + PrefabUtility.IsPartOfPrefabInstance(go)); | |
EditorGUILayout.LabelField("IsPartOfPrefabThatCanBeAppliedTo", "" + PrefabUtility.IsPartOfPrefabThatCanBeAppliedTo(go)); | |
EditorGUILayout.LabelField("IsPartOfRegularPrefab", "" + PrefabUtility.IsPartOfRegularPrefab(go)); | |
EditorGUILayout.LabelField("IsPartOfVariantPrefab", "" + PrefabUtility.IsPartOfVariantPrefab(go)); | |
EditorGUILayout.LabelField("IsPrefabAssetMissing", "" + PrefabUtility.IsPrefabAssetMissing(go)); | |
EditorGUILayout.ObjectField("GetCorrespondingObjectFromOriginalSource", PrefabUtility.GetCorrespondingObjectFromOriginalSource(go), typeof(GameObject), allowSceneObjects: true); | |
EditorGUILayout.ObjectField("GetCorrespondingObjectFromSource", PrefabUtility.GetCorrespondingObjectFromSource(go), typeof(GameObject), allowSceneObjects: true); | |
EditorGUILayout.ObjectField("GetIconForGameObject", PrefabUtility.GetIconForGameObject(go), typeof(Texture), allowSceneObjects: true); | |
EditorGUILayout.ObjectField("GetNearestPrefabInstanceRoot", PrefabUtility.GetNearestPrefabInstanceRoot(go), typeof(GameObject), allowSceneObjects: true); | |
EditorGUILayout.ObjectField("GetOutermostPrefabInstanceRoot", PrefabUtility.GetOutermostPrefabInstanceRoot(go), typeof(GameObject), allowSceneObjects: true); | |
EditorGUILayout.TextField("GetPrefabAssetPathOfNearestInstanceRoot", PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(go)); | |
EditorGUILayout.LabelField("GetPrefabAssetType", PrefabUtility.GetPrefabAssetType(go).ToString()); | |
EditorGUILayout.ObjectField("GetPrefabInstanceHandle", PrefabUtility.GetPrefabInstanceHandle(go), typeof(GameObject), allowSceneObjects: true); | |
EditorGUILayout.LabelField("GetPrefabInstanceStatus", PrefabUtility.GetPrefabInstanceStatus(go).ToString()); | |
} | |
EditorGUILayout.EndScrollView(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment