using System.Text;
using UnityEngine;
using UnityEditor;
class ShowAssetIds
{
[MenuItem("Assets/Show Asset Ids")]
static void MenuShowIds()
{
var stringBuilder = new StringBuilder();
foreach (var obj in AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(Selection.activeObject)))
{
string guid;
long file;
if (AssetDatabase.TryGetGUIDAndLocalFileIdentifier(obj, out guid, out file))
{
stringBuilder.AppendFormat("Asset: " + obj.name +
"\n Instance ID: " + obj.GetInstanceID() +
"\n GUID: " + guid +
"\n File ID: " + file);
}
}
Debug.Log(stringBuilder.ToString());
}
}
先创建这个脚本之后用
创建一个.asset文件(用.txt文件直接更改后缀名获得)内容大概是这样
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11500000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 67f26d1899724d6fa2d91a259dceae9f, type: 3}
m_Name: RandomSizeGen
m_EditorClassIdentifier:
这里面就一个guid需要根据实际进行填写
生成.asset绑定的脚本,大概这样
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.VisualScripting;
using UnityEditor;
public class MyClass : ScriptableObject
{
public int i;
public Transform t;
}
使用刚才那个脚本生成的这个按钮,在MyClass右键生成guid然后替换这部分
之后就能显示这样一个界面了
|