浏览代码

It is now possible to mark a master node as active in a shader graph (but not in others like sub graphs or remap graphs)

/main
Peter Bay Bastian 8 年前
当前提交
22ea3bd8
共有 6 个文件被更改,包括 97 次插入4 次删除
  1. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/DrawData/RemapMasterNodeDrawData.cs
  2. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/DrawData/SurfaceMasterDrawData.cs
  3. 13
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/MaterialGraph.cs
  4. 21
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AbstractMasterNode.cs
  5. 43
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/DrawData/MasterNodeDrawData.cs
  6. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/DrawData/MasterNodeDrawData.cs.meta

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/DrawData/RemapMasterNodeDrawData.cs


}
[Serializable]
public class RemapMasterNodeDrawData : MaterialNodeDrawData
public class RemapMasterNodeDrawData : MasterNodeDrawData
return new List<GraphElementData> { instance };
var controls = new List<GraphElementData>(base.GetControlData());
controls.Add(instance);
return controls;
}
}
}

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/DrawData/SurfaceMasterDrawData.cs


}
[Serializable]
public class SurfaceMasterDrawData : MaterialNodeDrawData
public class SurfaceMasterDrawData : MasterNodeDrawData
return new List<GraphElementData> { instance };
var controls = new List<GraphElementData>(base.GetControlData());
controls.Add(instance);
return controls;
}
}
}

13
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/MaterialGraph.cs


using System;
using System.Linq;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{

return found;
return GetNodes<IMasterNode>().FirstOrDefault();
}
set
{
var previousMaster = masterNode;
if (value == null)
m_ActiveMasterNodeGUID = Guid.NewGuid();
else
m_ActiveMasterNodeGUID = value.guid;
masterNode.onModified(masterNode, ModificationScope.Node);
previousMaster.onModified(previousMaster, ModificationScope.Node);
}
}

21
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AbstractMasterNode.cs


get { return false; }
}
public bool isActiveMaster
{
get
{
var graph = owner as MaterialGraph;
return graph != null && graph.masterNode == this;
}
set
{
var graph = owner as MaterialGraph;
if (graph == null || value == isActiveMaster)
return;
graph.masterNode = value ? this : null;
}
}
public bool canBeActiveMaster
{
get { return owner is MaterialGraph; }
}
public abstract string GetFullShader(GenerationMode mode, out List<PropertyGenerator.TextureInfo> configuredTextures);
public abstract string GetSubShader(GenerationMode mode, PropertyGenerator shaderPropertiesVisitor);
}

43
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/DrawData/MasterNodeDrawData.cs


using System;
using System.Collections.Generic;
using RMGUI.GraphView;
using UnityEditor.Graphing.Drawing;
using UnityEngine.MaterialGraph;
using UnityEngine;
namespace UnityEditor.MaterialGraph.Drawing
{
class MasterNodeControlDrawData : ControlDrawData
{
public override void OnGUIHandler()
{
base.OnGUIHandler();
var masterNode = node as AbstractMasterNode;
if (masterNode == null || !masterNode.canBeActiveMaster)
return;
using (new EditorGUI.DisabledScope(masterNode.isActiveMaster))
masterNode.isActiveMaster |= GUILayout.Button("Set active");
}
public override float GetHeight()
{
var masterNode = node as AbstractMasterNode;
if (masterNode == null || !masterNode.canBeActiveMaster)
return 0f;
return EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
}
}
[Serializable]
public class MasterNodeDrawData : MaterialNodeDrawData
{
protected override IEnumerable<GraphElementData> GetControlData()
{
var instance = CreateInstance<MasterNodeControlDrawData>();
instance.Initialize(node);
return new List<GraphElementData> { instance };
}
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/DrawData/MasterNodeDrawData.cs.meta


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