您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

39 行
1.1 KiB

using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
[CustomEditor(typeof(GPUCopyAsset))]
public class GPUCopyAssetEditor : Editor
{
GPUCopyAsset m_Target;
void OnEnable()
{
m_Target = (GPUCopyAsset)target;
}
public override void OnInspectorGUI()
{
if (GUILayout.Button("Generate"))
{
var assetpath = AssetDatabase.GetAssetPath(target);
var dirpath = Path.GetDirectoryName(assetpath);
var targetpathcs = dirpath + "/GPUCopy.cs";
var targetpathcc =dirpath + "/GPUCopy.compute";
string cc, cs;
m_Target.Generate(out cc, out cs);
File.WriteAllText(targetpathcc, cc);
File.WriteAllText(targetpathcs, cs);
AssetDatabase.StartAssetEditing();
AssetDatabase.ImportAsset(targetpathcc);
AssetDatabase.ImportAsset(targetpathcs);
AssetDatabase.StopAssetEditing();
}
base.OnInspectorGUI();
}
}