鸟语天空
预制类型——UnityEditor.PrefabType
post by:追风剑情 2017-9-27 14:16

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


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同理


评论:
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容