浏览代码

Temporary fix to open sub graphs in correct window class

/main
Peter Bay Bastian 7 年前
当前提交
9fb6ad45
共有 2 个文件被更改,包括 17 次插入3 次删除
  1. 5
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs
  2. 15
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderGraphImporter.cs

5
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs


void ToggleRequiresTime();
void ToSubGraph();
void Show();
void Focus();
Object selected { get; }
void ChangeSelection(Object newSelection);
}
public class MaterialGraphEditWindow : AbstractMaterialGraphEditWindow<UnityEngine.MaterialGraph.MaterialGraph>

15
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderGraphImporter.cs


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using JetBrains.Annotations;
using UnityEditor;

private static void ShowGraphEditWindow(string path)
{
var asset = AssetDatabase.LoadAssetAtPath<Object>(path);
var windows = Resources.FindObjectsOfTypeAll<MaterialGraphEditWindow>();
var extension = Path.GetExtension(path);
Type windowType;
if (extension == ".ShaderGraph")
windowType = typeof(MaterialGraphEditWindow);
else if (extension == ".ShaderSubGraph")
windowType = typeof(SubGraphEditWindow);
else
return;
var windows = Resources.FindObjectsOfTypeAll(windowType);
foreach (var w in windows)
foreach (var w in windows.OfType<IMaterialGraphEditWindow>())
{
if (w.selected == asset)
{

if (!foundWindow)
{
var window = ScriptableObject.CreateInstance<MaterialGraphEditWindow>();
var window = ScriptableObject.CreateInstance(windowType) as IMaterialGraphEditWindow;
window.Show();
window.ChangeSelection(asset);
}
正在加载...
取消
保存