Peter Bay Bastian
7 年前
当前提交
a92b64bb
共有 20 个文件被更改,包括 427 次插入 和 15 次删除
-
25MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/GraphInspectorPresenter.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs
-
38MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphInspectorView.cs
-
78MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/MaterialGraph.uss
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector.meta
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters.meta
-
10MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/AbstractNodeEditorPresenter.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/AbstractNodeEditorPresenter.cs.meta
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/IMGUISlotEditorPresenter.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/IMGUISlotEditorPresenter.cs.meta
-
45MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/StandardNodeEditorPresenter.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Presenters/StandardNodeEditorPresenter.cs.meta
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Views.meta
-
105MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Views/IMGUISlotEditorView.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Views/IMGUISlotEditorView.cs.meta
-
85MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Views/StandardNodeEditorView.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/Views/StandardNodeEditorView.cs.meta
|
|||
fileFormatVersion: 2 |
|||
guid: 1d1f4aaa81084a13aaeb78dfaf7d35d7 |
|||
timeCreated: 1503663057 |
|
|||
fileFormatVersion: 2 |
|||
guid: 2d08dfb360644031a5e64558d4a93263 |
|||
timeCreated: 1503663071 |
|
|||
using UnityEngine; |
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing.Inspector |
|||
{ |
|||
public abstract class AbstractNodeEditorPresenter : ScriptableObject |
|||
{ |
|||
public abstract void Initialize(INode node); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 97d910cfa5d2452e9ac7500b6cee25ab |
|||
timeCreated: 1503661223 |
|
|||
using UnityEngine; |
|||
using UnityEngine.Graphing; |
|||
using UnityEngine.MaterialGraph; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing.Inspector |
|||
{ |
|||
public class IMGUISlotEditorPresenter : ScriptableObject |
|||
{ |
|||
[SerializeField] |
|||
MaterialSlot m_Slot; |
|||
|
|||
public MaterialSlot slot |
|||
{ |
|||
get { return m_Slot; } |
|||
set { m_Slot = value; } |
|||
} |
|||
|
|||
public Vector4 value |
|||
{ |
|||
get { return m_Slot.currentValue; } |
|||
set |
|||
{ |
|||
if (value == slot.currentValue) |
|||
return; |
|||
slot.currentValue = value; |
|||
m_Slot.owner.onModified(m_Slot.owner, ModificationScope.Node); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7be91f540ac243ec9bf12002b0fb8c1d |
|||
timeCreated: 1504002750 |
|
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.Graphing; |
|||
using UnityEngine.MaterialGraph; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing.Inspector |
|||
{ |
|||
public sealed class StandardNodeEditorPresenter : AbstractNodeEditorPresenter |
|||
{ |
|||
[SerializeField] |
|||
AbstractMaterialNode m_Node; |
|||
|
|||
// TODO: Use abstract base class such that other editors can be used
|
|||
[SerializeField] |
|||
List<IMGUISlotEditorPresenter> m_SlotEditorPresenters; |
|||
|
|||
public AbstractMaterialNode node |
|||
{ |
|||
get { return m_Node; } |
|||
} |
|||
|
|||
public IEnumerable<IMGUISlotEditorPresenter> slotEditorPresenters |
|||
{ |
|||
get { return m_SlotEditorPresenters; } |
|||
} |
|||
|
|||
public override void Initialize(INode node) |
|||
{ |
|||
m_Node = node as AbstractMaterialNode; |
|||
m_SlotEditorPresenters = new List<IMGUISlotEditorPresenter>(); |
|||
foreach (var slot in node.GetInputSlots<MaterialSlot>()) |
|||
{ |
|||
if (slot.concreteValueType == ConcreteSlotValueType.Vector1 |
|||
|| slot.concreteValueType == ConcreteSlotValueType.Vector2 |
|||
|| slot.concreteValueType == ConcreteSlotValueType.Vector3 |
|||
|| slot.concreteValueType == ConcreteSlotValueType.Vector4) |
|||
{ |
|||
var slotEditorPresenter = CreateInstance<IMGUISlotEditorPresenter>(); |
|||
slotEditorPresenter.slot = slot; |
|||
m_SlotEditorPresenters.Add(slotEditorPresenter); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a0786fdde6014aa6b3222772757dbbb5 |
|||
timeCreated: 1503661346 |
|
|||
fileFormatVersion: 2 |
|||
guid: 0969ff891b874694aa732e1240ee159b |
|||
timeCreated: 1503663067 |
|
|||
using System; |
|||
using UnityEditor.Experimental.UIElements.GraphView; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.UIElements; |
|||
using UnityEngine.MaterialGraph; |
|||
using Object = UnityEngine.Object; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing.Inspector |
|||
{ |
|||
public class IMGUISlotEditorView : DataWatchContainer |
|||
{ |
|||
[SerializeField] |
|||
IMGUISlotEditorPresenter m_Presenter; |
|||
|
|||
ConcreteSlotValueType m_CurrentValueType = ConcreteSlotValueType.Error; |
|||
|
|||
public override void OnDataChanged() |
|||
{ |
|||
if (presenter == null) |
|||
{ |
|||
Clear(); |
|||
return; |
|||
} |
|||
|
|||
if (presenter.slot.concreteValueType == m_CurrentValueType) |
|||
return; |
|||
|
|||
Clear(); |
|||
m_CurrentValueType = presenter.slot.concreteValueType; |
|||
|
|||
Action onGUIHandler; |
|||
if (presenter.slot.concreteValueType == ConcreteSlotValueType.Vector4) |
|||
onGUIHandler = Vector4OnGUIHandler; |
|||
else if (presenter.slot.concreteValueType == ConcreteSlotValueType.Vector3) |
|||
onGUIHandler = Vector3OnGUIHandler; |
|||
else if (presenter.slot.concreteValueType == ConcreteSlotValueType.Vector2) |
|||
onGUIHandler = Vector2OnGUIHandler; |
|||
else if (presenter.slot.concreteValueType == ConcreteSlotValueType.Vector1) |
|||
onGUIHandler = Vector1OnGUIHandler; |
|||
else |
|||
return; |
|||
|
|||
Add(new IMGUIContainer(onGUIHandler) { executionContext = presenter.GetInstanceID() }); |
|||
} |
|||
|
|||
void Vector4OnGUIHandler() |
|||
{ |
|||
if (presenter.slot == null) |
|||
return; |
|||
var previousWideMode = EditorGUIUtility.wideMode; |
|||
EditorGUIUtility.wideMode = true; |
|||
presenter.value = EditorGUILayout.Vector4Field(presenter.slot.displayName, presenter.value); |
|||
EditorGUIUtility.wideMode = previousWideMode; |
|||
} |
|||
|
|||
void Vector3OnGUIHandler() |
|||
{ |
|||
if (presenter.slot == null) |
|||
return; |
|||
var previousWideMode = EditorGUIUtility.wideMode; |
|||
EditorGUIUtility.wideMode = true; |
|||
presenter.value = EditorGUILayout.Vector3Field(presenter.slot.displayName, presenter.value); |
|||
EditorGUIUtility.wideMode = previousWideMode; |
|||
} |
|||
|
|||
void Vector2OnGUIHandler() |
|||
{ |
|||
if (presenter.slot == null) |
|||
return; |
|||
var previousWideMode = EditorGUIUtility.wideMode; |
|||
EditorGUIUtility.wideMode = true; |
|||
presenter.value = EditorGUILayout.Vector2Field(presenter.slot.displayName, presenter.value); |
|||
EditorGUIUtility.wideMode = previousWideMode; |
|||
} |
|||
|
|||
void Vector1OnGUIHandler() |
|||
{ |
|||
if (presenter.slot == null) |
|||
return; |
|||
var previousWideMode = EditorGUIUtility.wideMode; |
|||
EditorGUIUtility.wideMode = true; |
|||
presenter.value = new Vector4(EditorGUILayout.FloatField(presenter.slot.displayName, presenter.value.x), 0, 0, 0); |
|||
EditorGUIUtility.wideMode = previousWideMode; |
|||
} |
|||
|
|||
protected override Object[] toWatch |
|||
{ |
|||
get { return new Object[] { presenter }; } |
|||
} |
|||
|
|||
public IMGUISlotEditorPresenter presenter |
|||
{ |
|||
get { return m_Presenter; } |
|||
set |
|||
{ |
|||
if (value == m_Presenter) |
|||
return; |
|||
RemoveWatch(); |
|||
m_Presenter = value; |
|||
OnDataChanged(); |
|||
AddWatch(); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 1c0c3a78bde740fba369b4d5a58d5354 |
|||
timeCreated: 1503663627 |
|
|||
using System.Linq; |
|||
using UnityEditor.Experimental.UIElements.GraphView; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.UIElements; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing.Inspector |
|||
{ |
|||
public class StandardNodeEditorView : DataWatchContainer |
|||
{ |
|||
VisualElement m_EditorTitle; |
|||
VisualElement m_SlotsContainer; |
|||
VisualElement m_DefaultSlotValuesSection; |
|||
|
|||
public StandardNodeEditorView() |
|||
{ |
|||
AddToClassList("nodeEditor"); |
|||
|
|||
var headerContainer = new VisualElement(); |
|||
headerContainer.AddToClassList("header"); |
|||
{ |
|||
m_EditorTitle = new VisualElement(); |
|||
m_EditorTitle.AddToClassList("title"); |
|||
headerContainer.Add(m_EditorTitle); |
|||
|
|||
var headerType = new VisualElement { text = "(node)" }; |
|||
headerType.AddToClassList("type"); |
|||
headerContainer.Add(headerType); |
|||
} |
|||
Add(headerContainer); |
|||
|
|||
m_DefaultSlotValuesSection = new VisualElement(); |
|||
m_DefaultSlotValuesSection.AddToClassList("section"); |
|||
{ |
|||
var sectionTitle = new VisualElement { text = "Default Slot Values" }; |
|||
sectionTitle.AddToClassList("title"); |
|||
m_DefaultSlotValuesSection.Add(sectionTitle); |
|||
|
|||
m_SlotsContainer = new VisualElement { name = "slots" }; |
|||
m_DefaultSlotValuesSection.Add(m_SlotsContainer); |
|||
} |
|||
Add(m_DefaultSlotValuesSection); |
|||
} |
|||
|
|||
[SerializeField] |
|||
StandardNodeEditorPresenter m_Presenter; |
|||
|
|||
public StandardNodeEditorPresenter presenter |
|||
{ |
|||
get { return m_Presenter; } |
|||
set |
|||
{ |
|||
if (value == m_Presenter) |
|||
return; |
|||
RemoveWatch(); |
|||
m_Presenter = value; |
|||
OnDataChanged(); |
|||
AddWatch(); |
|||
} |
|||
} |
|||
|
|||
public override void OnDataChanged() |
|||
{ |
|||
if (presenter == null) |
|||
return; |
|||
|
|||
m_EditorTitle.text = presenter.node.name; |
|||
|
|||
m_SlotsContainer.Clear(); |
|||
foreach (var slotEditorPresenter in presenter.slotEditorPresenters) |
|||
{ |
|||
m_SlotsContainer.Add(new IMGUISlotEditorView { presenter = slotEditorPresenter }); |
|||
} |
|||
|
|||
if (m_SlotsContainer.Any()) |
|||
m_DefaultSlotValuesSection.RemoveFromClassList("hidden"); |
|||
else |
|||
m_DefaultSlotValuesSection.AddToClassList("hidden"); |
|||
} |
|||
|
|||
protected override Object[] toWatch |
|||
{ |
|||
get { return new Object[] { presenter }; } |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 61b4edcdcc1949a29fa0b42e25241429 |
|||
timeCreated: 1503661486 |
撰写
预览
正在加载...
取消
保存
Reference in new issue