Boat Attack使用了Universal RP的许多新图形功能,可以用于探索 Universal RP 的使用方式和技巧。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

62 行
2.1 KiB

using System;
using System.IO;
using UnityEditor.Callbacks;
using UnityEditor.Experimental.AssetImporters;
using UnityEditor.ShaderGraph.Drawing;
using UnityEngine;
namespace UnityEditor.ShaderGraph
{
[CustomEditor(typeof(ShaderGraphImporter))]
class ShaderGraphImporterEditor : ScriptedImporterEditor
{
protected override bool needsApplyRevert => false;
public override void OnInspectorGUI()
{
if (GUILayout.Button("Open Shader Editor"))
{
AssetImporter importer = target as AssetImporter;
Debug.Assert(importer != null, "importer != null");
ShowGraphEditWindow(importer.assetPath);
}
ApplyRevertGUI();
}
internal static bool ShowGraphEditWindow(string path)
{
var guid = AssetDatabase.AssetPathToGUID(path);
var extension = Path.GetExtension(path);
if (string.IsNullOrEmpty(extension))
return false;
// Path.GetExtension returns the extension prefixed with ".", so we remove it. We force lower case such that
// the comparison will be case-insensitive.
extension = extension.Substring(1).ToLowerInvariant();
if (extension != ShaderGraphImporter.Extension && extension != ShaderSubGraphImporter.Extension)
return false;
foreach (var w in Resources.FindObjectsOfTypeAll<MaterialGraphEditWindow>())
{
if (w.selectedGuid == guid)
{
w.Focus();
return true;
}
}
var window = EditorWindow.CreateWindow<MaterialGraphEditWindow>(typeof(MaterialGraphEditWindow), typeof(SceneView));
window.Initialize(guid);
window.Focus();
return true;
}
[OnOpenAsset(0)]
public static bool OnOpenAsset(int instanceID, int line)
{
var path = AssetDatabase.GetAssetPath(instanceID);
return ShowGraphEditWindow(path);
}
}
}