浏览代码

Undo handling for adding/removing shader properties

/main
Peter Bay Bastian 7 年前
当前提交
e3cb9212
共有 2 个文件被更改,包括 22 次插入15 次删除
  1. 36
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs
  2. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/ShaderPropertyView.cs

36
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs


using System;
using System;
using UnityEngine.Experimental.UIElements.StyleEnums;
using UnityEngine.Experimental.UIElements.StyleSheets;
using UnityEngine.Graphing;
using UnityEngine.Experimental.UIElements.StyleEnums;
using UnityEngine.Experimental.UIElements.StyleSheets;
using UnityEngine.Graphing;
using UnityEngine.MaterialGraph;
namespace UnityEditor.MaterialGraph.Drawing.Inspector

}
bottomContainer.Add(propertiesContainer);
m_Preview = new Image { name = "preview", image = Texture2D.blackTexture};
m_Preview = new Image { name = "preview", image = Texture2D.blackTexture };
bottomContainer.Add(m_Preview);
}
Add(bottomContainer);

// - SubGraphOutputNode
m_TypeMapper = new TypeMapper(typeof(INode), typeof(AbstractNodeEditorView), typeof(StandardNodeEditorView))
{
// { typeof(AbstractSurfaceMasterNode), typeof(SurfaceMasterNodeEditorView) }
// { typeof(AbstractSurfaceMasterNode), typeof(SurfaceMasterNodeEditorView) }
};
}

gm.AddItem(new GUIContent("Float"), false, () => m_Presenter.graph.AddShaderProperty(new FloatShaderProperty()));
gm.AddItem(new GUIContent("Vector2"), false, () => m_Presenter.graph.AddShaderProperty(new Vector2ShaderProperty()));
gm.AddItem(new GUIContent("Vector3"), false, () => m_Presenter.graph.AddShaderProperty(new Vector3ShaderProperty()));
gm.AddItem(new GUIContent("Vector4"), false, () => m_Presenter.graph.AddShaderProperty(new Vector4ShaderProperty()));
gm.AddItem(new GUIContent("Color"), false, () => m_Presenter.graph.AddShaderProperty(new ColorShaderProperty()));
gm.AddItem(new GUIContent("Texture"), false, () => m_Presenter.graph.AddShaderProperty(new TextureShaderProperty()));
gm.ShowAsContext();
}
gm.AddItem(new GUIContent("Float"), false, () => AddProperty(new FloatShaderProperty()));
gm.AddItem(new GUIContent("Vector2"), false, () => AddProperty(new Vector2ShaderProperty()));
gm.AddItem(new GUIContent("Vector3"), false, () => AddProperty(new Vector3ShaderProperty()));
gm.AddItem(new GUIContent("Vector4"), false, () => AddProperty(new Vector4ShaderProperty()));
gm.AddItem(new GUIContent("Color"), false, () => AddProperty(new ColorShaderProperty()));
gm.AddItem(new GUIContent("Texture"), false, () => AddProperty(new TextureShaderProperty()));
gm.ShowAsContext();
}
void AddProperty(IShaderProperty property)
{
m_Presenter.graph.owner.RegisterCompleteObjectUndo("Add Property");
m_Presenter.graph.AddShaderProperty(property);
}
public void OnChange(GraphInspectorPresenter.ChangeType changeType)
{

m_PropertyItems.Add(new ShaderPropertyView(m_Graph, property));
m_Graph.onChange += OnGraphChange;
}
}
}
}
void OnGraphChange(GraphChange change)

1
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/ShaderPropertyView.cs


void OnClickRemove()
{
graph.owner.RegisterCompleteObjectUndo("Remove Property");
graph.RemoveShaderProperty(property.guid);
NotifyNodes();
}

正在加载...
取消
保存