浏览代码

Reenable sub graphs

/main
Tim Cooper 8 年前
当前提交
c8eb7c61
共有 4 个文件被更改,包括 56 次插入11 次删除
  1. 22
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Presenters/TitleBarPresenter.cs
  2. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/MaterialSubGraphAsset.cs
  3. 30
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderSubGraphImporter.cs
  4. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderSubGraphImporter.cs.meta

22
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/Presenters/TitleBarPresenter.cs


class CallbackData
{
public MaterialGraphAsset asset;
public IGraphAsset asset;
public static List<MaterialGraphAsset> FindAssets()
public static List<IGraphAsset> FindAssets()
var assets = new List<MaterialGraphAsset>();
string[] guids = AssetDatabase.FindAssets(string.Format("t:MaterialGraphAsset", typeof(MaterialGraphAsset)));
for( int i = 0; i < guids.Length; i++ )
var assets = new List<IGraphAsset>();
List<string> guids = AssetDatabase.FindAssets(string.Format("t:MaterialGraphAsset", typeof(MaterialGraphAsset))).ToList();
guids.AddRange( AssetDatabase.FindAssets(string.Format("t:MaterialSubGraphAsset", typeof(MaterialSubGraphAsset))));
for( int i = 0; i < guids.Count; i++ )
MaterialGraphAsset asset = AssetDatabase.LoadAssetAtPath<MaterialGraphAsset>( assetPath );
if( asset != null )
ScriptableObject asset = AssetDatabase.LoadAssetAtPath<ScriptableObject>( assetPath );
if( asset != null && EditorUtility.IsPersistent(asset) && asset is IGraphAsset)
assets.Add(asset);
assets.Add((IGraphAsset)asset);
}
}
return assets;

{
var options = FindAssets().Where (x => EditorUtility.IsPersistent (x)).ToList ();
var options = FindAssets();
gm.AddItem (new GUIContent (AssetDatabase.GetAssetPath (option)), false, Callback, new CallbackData(){asset = option, owner = m_Owner});
gm.AddItem (new GUIContent (AssetDatabase.GetAssetPath (option.GetScriptableObject())), false, Callback, new CallbackData(){asset = option, owner = m_Owner});
}
gm.ShowAsContext ();

3
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/MaterialSubGraphAsset.cs


public SubGraph subGraph
{
get { return m_MaterialSubGraph; }
get { return m_MaterialSubGraph; }
set { m_MaterialSubGraph = value; }
}
public void PostCreate()

30
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderSubGraphImporter.cs


using UnityEditor.Experimental.AssetImporters;
using UnityEngine.MaterialGraph;
using UnityEngine;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
#if UNITY_EDITOR
using System.Reflection;
using UnityEditor;
#endif
using UnityEngine.Graphing;
using System.Text;
[ScriptedImporter(1, "ShaderSubGraph")]
public class ShaderSubGraphImporter : ScriptedImporter
{
public override void OnImportAsset(AssetImportContext ctx)
{
var textGraph = File.ReadAllText(ctx.assetPath, Encoding.UTF8);
var graph = JsonUtility.FromJson<SubGraph>(textGraph);
if (graph == null)
return;
var graphAsset = ScriptableObject.CreateInstance<MaterialSubGraphAsset> ();
graphAsset.subGraph = graph;
ctx.SetMainAsset("MainAsset", graphAsset);
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderSubGraphImporter.cs.meta


fileFormatVersion: 2
guid: 60072b568d64c40a485e0fc55012dc9f
timeCreated: 1495613811
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存