initial commit

This commit is contained in:
Jo 2025-01-07 02:06:59 +01:00
parent 6715289efe
commit 788c3389af
37645 changed files with 2526849 additions and 80 deletions

View file

@ -0,0 +1,32 @@
using System;
using UnityEditor.Graphing;
using UnityEngine;
using UnityEngine.UIElements;
namespace UnityEditor.ShaderGraph.Drawing.Slots
{
class BooleanSlotControlView : VisualElement
{
BooleanMaterialSlot m_Slot;
public BooleanSlotControlView(BooleanMaterialSlot slot)
{
styleSheets.Add(Resources.Load<StyleSheet>("Styles/Controls/BooleanSlotControlView"));
m_Slot = slot;
var toggleField = new Toggle() { value = m_Slot.value };
toggleField.OnToggleChanged(OnChangeToggle);
Add(toggleField);
}
void OnChangeToggle(ChangeEvent<bool> evt)
{
if (evt.newValue != m_Slot.value)
{
m_Slot.owner.owner.owner.RegisterCompleteObjectUndo("Toggle Change");
m_Slot.value = evt.newValue;
m_Slot.owner.Dirty(ModificationScope.Node);
}
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7fc29d436587748dcaaefd8669c3d946
timeCreated: 1510659384

View file

@ -0,0 +1,36 @@
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Internal;
using UnityEngine;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace UnityEditor.ShaderGraph.Drawing.Slots
{
class ColorRGBSlotControlView : VisualElement
{
ColorRGBMaterialSlot m_Slot;
public ColorRGBSlotControlView(ColorRGBMaterialSlot slot)
{
styleSheets.Add(Resources.Load<StyleSheet>("Styles/Controls/ColorRGBSlotControlView"));
m_Slot = slot;
var colorField = new ColorField
{
value = new Color(slot.value.x, slot.value.y, slot.value.z, 0),
showEyeDropper = false,
showAlpha = false,
hdr = (slot.colorMode == ColorMode.HDR)
};
colorField.RegisterValueChangedCallback(OnValueChanged);
Add(colorField);
}
void OnValueChanged(ChangeEvent<Color> evt)
{
m_Slot.owner.owner.owner.RegisterCompleteObjectUndo("Color Change");
m_Slot.value = new Vector3(evt.newValue.r, evt.newValue.g, evt.newValue.b);
m_Slot.owner.Dirty(ModificationScope.Node);
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a184620cc50fd2e40a845d6ebb39529e
timeCreated: 1510659384

View file

@ -0,0 +1,29 @@
using UnityEditor.Graphing;
using UnityEngine;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace UnityEditor.ShaderGraph.Drawing.Slots
{
class ColorRGBASlotControlView : VisualElement
{
ColorRGBAMaterialSlot m_Slot;
public ColorRGBASlotControlView(ColorRGBAMaterialSlot slot)
{
styleSheets.Add(Resources.Load<StyleSheet>("Styles/Controls/ColorRGBASlotControlView"));
m_Slot = slot;
var colorField = new ColorField { value = slot.value, showEyeDropper = false };
colorField.RegisterValueChangedCallback(OnValueChanged);
Add(colorField);
}
void OnValueChanged(ChangeEvent<Color> evt)
{
m_Slot.owner.owner.owner.RegisterCompleteObjectUndo("Color Change");
m_Slot.value = evt.newValue;
m_Slot.owner.Dirty(ModificationScope.Node);
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 07332ea5e51a4bd3b6fb63e8e07cc30b
timeCreated: 1510659384

View file

@ -0,0 +1,35 @@
using System;
using UnityEditor.Graphing;
using UnityEngine;
using Object = UnityEngine.Object;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace UnityEditor.ShaderGraph.Drawing.Slots
{
class CubemapSlotControlView : VisualElement
{
CubemapInputMaterialSlot m_Slot;
public CubemapSlotControlView(CubemapInputMaterialSlot slot)
{
styleSheets.Add(Resources.Load<StyleSheet>("Styles/Controls/CubemapSlotControlView"));
m_Slot = slot;
var objectField = new ObjectField { objectType = typeof(Cubemap), value = m_Slot.cubemap };
objectField.RegisterValueChangedCallback(OnValueChanged);
Add(objectField);
}
void OnValueChanged(ChangeEvent<Object> evt)
{
var cubemap = evt.newValue as Cubemap;
if (cubemap != m_Slot.cubemap)
{
m_Slot.owner.owner.owner.RegisterCompleteObjectUndo("Change Cubemap");
m_Slot.cubemap = cubemap;
m_Slot.owner.Dirty(ModificationScope.Node);
}
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b54f542a9d5f7b84e974b54d625d73ea
timeCreated: 1509718979

View file

@ -0,0 +1,57 @@
using System;
using UnityEditor.Graphing;
using UnityEngine;
using UnityEditor.ShaderGraph;
using UnityEditor.ShaderGraph.Drawing.Controls;
using Object = UnityEngine.Object;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
using UnityEngine.UIElements.StyleSheets;
namespace UnityEditor.ShaderGraph.Drawing.Slots
{
class GradientSlotControlView : VisualElement
{
GradientInputMaterialSlot m_Slot;
[SerializeField]
GradientObject m_GradientObject;
[SerializeField]
SerializedObject m_SerializedObject;
public GradientSlotControlView(GradientInputMaterialSlot slot)
{
m_Slot = slot;
styleSheets.Add(Resources.Load<StyleSheet>("Styles/Controls/GradientSlotControlView"));
m_GradientObject = ScriptableObject.CreateInstance<GradientObject>();
m_GradientObject.gradient = new Gradient();
m_SerializedObject = new SerializedObject(m_GradientObject);
m_GradientObject.gradient.SetKeys(m_Slot.value.colorKeys, m_Slot.value.alphaKeys);
m_GradientObject.gradient.mode = m_Slot.value.mode;
var gradientField = new GradientField() { value = m_GradientObject.gradient, colorSpace = ColorSpace.Linear };
gradientField.RegisterValueChangedCallback(OnValueChanged);
Add(gradientField);
}
void OnValueChanged(ChangeEvent<Gradient> evt)
{
m_SerializedObject.Update();
if (!evt.newValue.Equals(m_Slot.value))
{
m_Slot.owner.owner.owner.RegisterCompleteObjectUndo("Change Gradient");
m_GradientObject.gradient.SetKeys(evt.newValue.colorKeys, evt.newValue.alphaKeys);
m_GradientObject.gradient.mode = evt.newValue.mode;
m_SerializedObject.ApplyModifiedProperties();
m_Slot.value = m_GradientObject.gradient;
m_Slot.owner.Dirty(ModificationScope.Node);
}
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e5c808b828bf44895b35be954f0906e5
timeCreated: 1510659384

View file

@ -0,0 +1,15 @@
using System;
using UnityEngine;
using UnityEngine.UIElements;
namespace UnityEditor.ShaderGraph.Drawing.Slots
{
class LabelSlotControlView : VisualElement
{
public LabelSlotControlView(string label)
{
var labelField = new Label(label);
Add(labelField);
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b7e0bdc2deb5a43aca74fd1e84c94cfa
timeCreated: 1509718979

View file

@ -0,0 +1,82 @@
using System;
using System.Globalization;
using UnityEditor.Graphing;
using UnityEngine;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace UnityEditor.ShaderGraph.Drawing.Slots
{
class MultiFloatSlotControlView : VisualElement
{
readonly AbstractMaterialNode m_Node;
readonly Func<Vector4> m_Get;
readonly Action<Vector4> m_Set;
int m_UndoGroup = -1;
public MultiFloatSlotControlView(AbstractMaterialNode node, string[] labels, Func<Vector4> get, Action<Vector4> set)
{
styleSheets.Add(Resources.Load<StyleSheet>("Styles/Controls/MultiFloatSlotControlView"));
m_Node = node;
m_Get = get;
m_Set = set;
var initialValue = get();
for (var i = 0; i < labels.Length; i++)
AddField(initialValue, i, labels[i]);
}
void AddField(Vector4 initialValue, int index, string subLabel)
{
var dummy = new VisualElement { name = "dummy" };
var label = new Label(subLabel);
dummy.Add(label);
Add(dummy);
var field = new FloatField { userData = index, value = initialValue[index] };
var dragger = new FieldMouseDragger<double>(field);
dragger.SetDragZone(label);
field.Q("unity-text-input").RegisterCallback<KeyDownEvent>(evt =>
{
// Record Undo for input field edit
if (m_UndoGroup == -1)
{
m_UndoGroup = Undo.GetCurrentGroup();
m_Node.owner.owner.RegisterCompleteObjectUndo("Change " + m_Node.name);
}
// Handle scaping input field edit
if (evt.keyCode == KeyCode.Escape && m_UndoGroup > -1)
{
Undo.RevertAllDownToGroup(m_UndoGroup);
m_UndoGroup = -1;
evt.StopPropagation();
}
// Dont record Undo again until input field is unfocused
m_UndoGroup++;
this.MarkDirtyRepaint();
});
// Called after KeyDownEvent
field.RegisterValueChangedCallback(evt =>
{
// Only true when setting value via FieldMouseDragger
// Undo recorded once per dragger release
if (m_UndoGroup == -1)
{
m_Node.owner.owner.RegisterCompleteObjectUndo("Change " + m_Node.name);
}
var value = m_Get();
if (value[index] != (float)evt.newValue)
{
value[index] = (float)evt.newValue;
m_Set(value);
m_Node.Dirty(ModificationScope.Node);
}
});
// Reset UndoGroup when done editing input field & update title
field.Q("unity-text-input").RegisterCallback<FocusOutEvent>(evt =>
{
m_Node.owner.owner.isDirty = true;
m_UndoGroup = -1;
});
Add(field);
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6511e850402b445298bdb3256d9a131b
timeCreated: 1509721796

View file

@ -0,0 +1,82 @@
using System;
using System.Globalization;
using UnityEditor.Graphing;
using UnityEngine;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace UnityEditor.ShaderGraph.Drawing.Slots
{
class MultiIntegerSlotControlView : VisualElement
{
readonly AbstractMaterialNode m_Node;
readonly Func<Vector4> m_Get;
readonly Action<Vector4> m_Set;
int m_UndoGroup = -1;
public MultiIntegerSlotControlView(AbstractMaterialNode node, string[] labels, Func<Vector4> get, Action<Vector4> set)
{
styleSheets.Add(Resources.Load<StyleSheet>("Styles/Controls/MultiIntegerSlotControlView"));
m_Node = node;
m_Get = get;
m_Set = set;
var initialValue = get();
for (var i = 0; i < labels.Length; i++)
AddField(initialValue, i, labels[i]);
}
void AddField(Vector4 initialValue, int index, string subLabel)
{
var dummy = new VisualElement { name = "dummy" };
var label = new Label(subLabel);
dummy.Add(label);
Add(dummy);
var field = new IntegerField { userData = index, value = (int)initialValue[index] };
var dragger = new FieldMouseDragger<int>(field);
dragger.SetDragZone(label);
field.Q("unity-text-input").RegisterCallback<KeyDownEvent>(evt =>
{
// Record Undo for input field edit
if (m_UndoGroup == -1)
{
m_UndoGroup = Undo.GetCurrentGroup();
m_Node.owner.owner.RegisterCompleteObjectUndo("Change " + m_Node.name);
}
// Handle scaping input field edit
if (evt.keyCode == KeyCode.Escape && m_UndoGroup > -1)
{
Undo.RevertAllDownToGroup(m_UndoGroup);
m_UndoGroup = -1;
evt.StopPropagation();
}
// Dont record Undo again until input field is unfocused
m_UndoGroup++;
this.MarkDirtyRepaint();
});
// Called after KeyDownEvent
field.RegisterValueChangedCallback(evt =>
{
// Only true when setting value via FieldMouseDragger
// Undo recorded once per dragger release
if (m_UndoGroup == -1)
{
m_Node.owner.owner.RegisterCompleteObjectUndo("Change " + m_Node.name);
}
var value = m_Get();
if (value[index] != (float)evt.newValue)
{
value[index] = (float)evt.newValue;
m_Set(value);
m_Node.Dirty(ModificationScope.Node);
}
});
// Reset UndoGroup when done editing input field & update title
field.Q("unity-text-input").RegisterCallback<FocusOutEvent>(evt =>
{
m_Node.owner.owner.isDirty = true;
m_UndoGroup = -1;
});
Add(field);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b854c7256bfe15c42918d727349e387c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,14 @@
using System;
using UnityEditor.Graphing;
using UnityEngine;
using UnityEngine.UIElements;
namespace UnityEditor.ShaderGraph.Drawing.Slots
{
class PropertyConnectionStateSlotControlView : VisualElement
{
public PropertyConnectionStateSlotControlView(PropertyConnectionStateMaterialSlot slot)
{
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ce60f7df8973ec749b679977e5fd7687
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,33 @@
using System;
using UnityEditor.Graphing;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UIElements;
namespace UnityEditor.ShaderGraph.Drawing.Slots
{
class ScreenPositionSlotControlView : VisualElement
{
ScreenPositionMaterialSlot m_Slot;
public ScreenPositionSlotControlView(ScreenPositionMaterialSlot slot)
{
styleSheets.Add(Resources.Load<StyleSheet>("Styles/Controls/ScreenPositionSlotControlView"));
m_Slot = slot;
var enumField = new EnumField(slot.screenSpaceType);
enumField.RegisterValueChangedCallback(OnValueChanged);
Add(enumField);
}
void OnValueChanged(ChangeEvent<Enum> evt)
{
var screenSpaceType = (ScreenSpaceType)evt.newValue;
if (screenSpaceType != m_Slot.screenSpaceType)
{
m_Slot.owner.owner.owner.RegisterCompleteObjectUndo("Change Screen Space Type");
m_Slot.screenSpaceType = screenSpaceType;
m_Slot.owner.Dirty(ModificationScope.Graph);
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1774f54355319894888ab5ec90b728e7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,34 @@
using System;
using UnityEditor.Graphing;
using UnityEngine;
using Object = UnityEngine.Object;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace UnityEditor.ShaderGraph.Drawing.Slots
{
class Texture3DSlotControlView : VisualElement
{
Texture3DInputMaterialSlot m_Slot;
public Texture3DSlotControlView(Texture3DInputMaterialSlot slot)
{
m_Slot = slot;
styleSheets.Add(Resources.Load<StyleSheet>("Styles/Controls/Texture3DSlotControlView"));
var objectField = new ObjectField { objectType = typeof(Texture3D), value = m_Slot.texture };
objectField.RegisterValueChangedCallback(OnValueChanged);
Add(objectField);
}
void OnValueChanged(ChangeEvent<Object> evt)
{
var texture = evt.newValue as Texture3D;
if (texture != m_Slot.texture)
{
m_Slot.owner.owner.owner.RegisterCompleteObjectUndo("Change Texture");
m_Slot.texture = texture;
m_Slot.owner.Dirty(ModificationScope.Node);
}
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 843052fb41ee94a92b93c2070c1bf577
timeCreated: 1509718979

View file

@ -0,0 +1,34 @@
using System;
using UnityEditor.Graphing;
using UnityEngine;
using Object = UnityEngine.Object;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace UnityEditor.ShaderGraph.Drawing.Slots
{
class TextureArraySlotControlView : VisualElement
{
Texture2DArrayInputMaterialSlot m_Slot;
public TextureArraySlotControlView(Texture2DArrayInputMaterialSlot slot)
{
m_Slot = slot;
styleSheets.Add(Resources.Load<StyleSheet>("Styles/Controls/TextureArraySlotControlView"));
var objectField = new ObjectField { objectType = typeof(Texture2DArray), value = m_Slot.textureArray };
objectField.RegisterValueChangedCallback(OnValueChanged);
Add(objectField);
}
void OnValueChanged(ChangeEvent<Object> evt)
{
var textureArray = evt.newValue as Texture2DArray;
if (textureArray != m_Slot.textureArray)
{
m_Slot.owner.owner.owner.RegisterCompleteObjectUndo("Change Texture Array");
m_Slot.textureArray = textureArray;
m_Slot.owner.Dirty(ModificationScope.Node);
}
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b65e883d3170e4edca841ea6a8fca626
timeCreated: 1509718979

View file

@ -0,0 +1,34 @@
using System;
using UnityEditor.Graphing;
using UnityEngine;
using Object = UnityEngine.Object;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace UnityEditor.ShaderGraph.Drawing.Slots
{
class TextureSlotControlView : VisualElement
{
Texture2DInputMaterialSlot m_Slot;
public TextureSlotControlView(Texture2DInputMaterialSlot slot)
{
m_Slot = slot;
styleSheets.Add(Resources.Load<StyleSheet>("Styles/Controls/TextureSlotControlView"));
var objectField = new ObjectField { objectType = typeof(Texture), value = m_Slot.texture };
objectField.RegisterValueChangedCallback(OnValueChanged);
Add(objectField);
}
void OnValueChanged(ChangeEvent<Object> evt)
{
var texture = evt.newValue as Texture;
if (texture != m_Slot.texture)
{
m_Slot.owner.owner.owner.RegisterCompleteObjectUndo("Change Texture");
m_Slot.texture = texture;
m_Slot.owner.Dirty(ModificationScope.Node);
}
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 49f18880b4854ccc8f383c55a7bc47b3
timeCreated: 1509718979

View file

@ -0,0 +1,34 @@
using System;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Internal;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UIElements;
namespace UnityEditor.ShaderGraph.Drawing.Slots
{
class UVSlotControlView : VisualElement
{
UVMaterialSlot m_Slot;
public UVSlotControlView(UVMaterialSlot slot)
{
styleSheets.Add(Resources.Load<StyleSheet>("Styles/Controls/UVSlotControlView"));
m_Slot = slot;
var enumField = new EnumField(slot.channel);
enumField.RegisterValueChangedCallback(OnValueChanged);
Add(enumField);
}
void OnValueChanged(ChangeEvent<Enum> evt)
{
var channel = (UVChannel)evt.newValue;
if (channel != m_Slot.channel)
{
m_Slot.owner.owner.owner.RegisterCompleteObjectUndo("Change UV Channel");
m_Slot.channel = channel;
m_Slot.owner.Dirty(ModificationScope.Graph);
}
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f19b65893a414156825079dfc9a6dea3
timeCreated: 1509961226