预制类型——UnityEditor.PrefabType

作者:追风剑情 发布于:2017-9-27 14:16 分类:Unity3d

先写个脚本用来打印选中的对象所属类型


using UnityEngine;
using UnityEditor;

public class TestEditor : MonoBehaviour {

    [MenuItem("Assets/ShowSelectionType", false, 0)]
    private static void ShowSelectionType()
    {
        UnityEngine.Object obj = Selection.activeObject;
        Debug.Log(PrefabUtility.GetPrefabType(obj));
    }
}


PrefabType.Prefab

11111.png

PrefabType.PrefabInstance

把Prefab从Project面板拖到Hierarchy并改名为PrefabInstance

22222.png

PrefabType.MissingPrefabInstance

在Project里随便创建个prefab并拖到Hierarchy改名为MissingPrefabInstance,然后把Project里的这个prefab删除掉(即,使它关联的prefab丢失)

33333.png

PrefabType.DisconnectedPrefabInstance

把原本在PrefabInstance下面的DisconnectedPrefabInstace拖出来,这就断开了此对象与Prefab的关联。

4444.png

PrefabType.ModelPrefabInstancePrefabType.DisconnectedPrefabInstance同理


标签: Unity3d

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号