Skip to content

Inspector Bugfixes #557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace UnityEditor.Rendering.HighDefinition
[Serializable]
[Title("Master", "Decal (HDRP)")]
[FormerName("UnityEditor.Experimental.Rendering.HDPipeline.DecalMasterNode")]
class DecalMasterNode : AbstractMaterialNode, IMasterNode, IHasSettings, ICanChangeShaderGUI, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
class DecalMasterNode : AbstractMaterialNode, IMasterNode, ICanChangeShaderGUI, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
{
public const string PositionSlotName = "Vertex Position";
public const string PositionSlotDisplayName = "Vertex Position";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace UnityEditor.Rendering.HighDefinition
{
[Serializable]
[Title("Master", "Eye (HDRP)(Preview)")]
class EyeMasterNode : AbstractMaterialNode, IMasterNode, IHasSettings, ICanChangeShaderGUI, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
class EyeMasterNode : AbstractMaterialNode, IMasterNode, ICanChangeShaderGUI, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
{
public const string PositionSlotName = "Vertex Position";
public const string PositionSlotDisplayName = "Vertex Position";
Expand Down Expand Up @@ -229,7 +229,7 @@ public ToggleData alphaTest
Dirty(ModificationScope.Topological);
}
}

[SerializeField]
bool m_AlphaToMask = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace UnityEditor.Rendering.HighDefinition
[Title("Master", "Fabric (HDRP)")]
[FormerName("UnityEditor.Experimental.Rendering.HDPipeline.FabricMasterNode")]
[FormerName("UnityEditor.ShaderGraph.FabricMasterNode")]
class FabricMasterNode : AbstractMaterialNode, IMasterNode, IHasSettings, ICanChangeShaderGUI, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
class FabricMasterNode : AbstractMaterialNode, IMasterNode, ICanChangeShaderGUI, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
{
public const string PositionSlotName = "Vertex Position";
public const string PositionSlotDisplayName = "Vertex Position";
Expand Down Expand Up @@ -234,7 +234,7 @@ public ToggleData alphaTest
Dirty(ModificationScope.Topological);
}
}

[SerializeField]
bool m_AlphaToMask = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace UnityEditor.Rendering.HighDefinition
[Serializable]
[Title("Master", "Hair (HDRP)")]
[FormerName("UnityEditor.Experimental.Rendering.HDPipeline.HairMasterNode")]
class HairMasterNode : AbstractMaterialNode, IMasterNode, IHasSettings, ICanChangeShaderGUI, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
class HairMasterNode : AbstractMaterialNode, IMasterNode, ICanChangeShaderGUI, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
{
public const string PositionSlotName = "Vertex Position";
public const string PositionSlotDisplayName = "Vertex Position";
Expand Down Expand Up @@ -259,7 +259,7 @@ public ToggleData alphaTest
Dirty(ModificationScope.Topological);
}
}

[SerializeField]
bool m_AlphaToMask = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace UnityEditor.Rendering.HighDefinition
[Title("Master", "Lit (HDRP)")]
[FormerName("UnityEditor.Experimental.Rendering.HDPipeline.HDLitMasterNode")]
[FormerName("UnityEditor.ShaderGraph.HDLitMasterNode")]
class HDLitMasterNode : AbstractMaterialNode, IMasterNode, IHasSettings, ICanChangeShaderGUI, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
class HDLitMasterNode : AbstractMaterialNode, IMasterNode, ICanChangeShaderGUI, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
{
public const string AlbedoSlotName = "Albedo";
public const string AlbedoDisplaySlotName = "BaseColor";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace UnityEditor.Rendering.HighDefinition
[Title("Master", "StackLit (HDRP)")]
[FormerName("UnityEditor.Experimental.Rendering.HDPipeline.StackLitMasterNode")]
[FormerName("UnityEditor.ShaderGraph.StackLitMasterNode")]
class StackLitMasterNode : AbstractMaterialNode, IMasterNode, IHasSettings, ICanChangeShaderGUI, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
class StackLitMasterNode : AbstractMaterialNode, IMasterNode, ICanChangeShaderGUI, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
{
public const string PositionSlotName = "Vertex Position";
public const string PositionSlotDisplayName = "Vertex Position";
Expand Down Expand Up @@ -360,7 +360,7 @@ public ToggleData alphaTest
Dirty(ModificationScope.Topological);
}
}

[SerializeField]
bool m_AlphaToMask = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace UnityEditor.Rendering.HighDefinition
[Serializable]
[FormerName("UnityEditor.Experimental.Rendering.HDPipeline.HDUnlitMasterNode")]
[Title("Master", "Unlit (HDRP)")]
class HDUnlitMasterNode : AbstractMaterialNode, IMasterNode, IHasSettings, ICanChangeShaderGUI, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
class HDUnlitMasterNode : AbstractMaterialNode, IMasterNode, ICanChangeShaderGUI, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
{
public const string ColorSlotName = "Color";
public const string AlphaSlotName = "Alpha";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace UnityEditor.Experimental.Rendering.Universal
[Serializable]
[Title("Master", "Sprite Lit (Experimental)")]
[FormerName("UnityEditor.Experimental.Rendering.LWRP.SpriteLitMasterNode")]
class SpriteLitMasterNode : AbstractMaterialNode, IMasterNode, IHasSettings, ICanChangeShaderGUI, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
class SpriteLitMasterNode : AbstractMaterialNode, IMasterNode, ICanChangeShaderGUI, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
{
public const string PositionName = "Vertex Position";
public const string NormalName = "Vertex Normal";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace UnityEditor.Experimental.Rendering.Universal
[Serializable]
[Title("Master", "Sprite Unlit (Experimental)")]
[FormerName("UnityEditor.Experimental.Rendering.LWRP.SpriteUnlitMasterNode")]
class SpriteUnlitMasterNode : AbstractMaterialNode, IMasterNode, IHasSettings, ICanChangeShaderGUI, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
class SpriteUnlitMasterNode : AbstractMaterialNode, IMasterNode, ICanChangeShaderGUI, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
{
public const string PositionName = "Vertex Position";
public const string NormalName = "Vertex Normal";
Expand Down
4 changes: 2 additions & 2 deletions com.unity.shadergraph/Editor/Data/Graphs/GraphData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ public List<string> BuildPropertyDisplayNameList(AbstractShaderProperty ignorePr
}
}
}

return result;
}

Expand Down Expand Up @@ -901,7 +901,7 @@ void ReplacePropertyNodeWithConcreteNodeNoValidate(PropertyNode propertyNode, bo

var node = property.ToConcreteNode() as AbstractMaterialNode;
if (node == null) // Some nodes have no concrete form
{
{
if (deleteNodeIfNoConcreteFormExists)
RemoveNodeNoValidate(propertyNode);
return;
Expand Down
9 changes: 0 additions & 9 deletions com.unity.shadergraph/Editor/Data/Interfaces/IHasSettings.cs

This file was deleted.

11 changes: 0 additions & 11 deletions com.unity.shadergraph/Editor/Data/Interfaces/IHasSettings.cs.meta

This file was deleted.

10 changes: 4 additions & 6 deletions com.unity.shadergraph/Editor/Data/Interfaces/IInspectable.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Reflection;
using Data.Interfaces;
using Drawing.Inspector;
Expand All @@ -8,16 +8,14 @@ namespace UnityEditor.ShaderGraph.Drawing
{
interface IInspectable
{
// Implementors can override this in order to display their desired string when selected and viewed through the inscetor
// Implementors can override this in order to display their desired string when selected and viewed through the inspector
string inspectorTitle { get; }

// This function should return the underlying data object that user wishes to expose to the Inspector
// For simple data properties like Integers/Floats this is the object that contains the properties
// For complex types like GraphData this is the GraphData itself, its up to the PropertyDrawer to define what it needs
object GetObjectToInspect();

// This function should return the property information of whatever object has been marked up for metadata gathering by the inspector
// This might be the same as the object returned by GetObjectToInspect(), it might not
PropertyInfo[] GetPropertyInfo();

// Used to provide any data needed by the property drawer from the inspectable
// The inspectorUpdateDelegate is used to trigger an inspector update
void SupplyDataToPropertyDrawer(IPropertyDrawer propertyDrawer, Action inspectorUpdateDelegate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace UnityEditor.ShaderGraph
{
[Serializable]
[Title("Master", "PBR")]
class PBRMasterNode : AbstractMaterialNode, IMasterNode, IHasSettings, ICanChangeShaderGUI, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
class PBRMasterNode : AbstractMaterialNode, IMasterNode, ICanChangeShaderGUI, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
{
public const string AlbedoSlotName = "Albedo";
public const string NormalSlotName = "Normal";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace UnityEditor.ShaderGraph
{
[Serializable]
[Title("Master", "Unlit")]
class UnlitMasterNode : AbstractMaterialNode, IMasterNode, IHasSettings, ICanChangeShaderGUI, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
class UnlitMasterNode : AbstractMaterialNode, IMasterNode, ICanChangeShaderGUI, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent
{
public const string ColorSlotName = "Color";
public const string AlphaSlotName = "Alpha";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace UnityEditor.ShaderGraph
{
[Serializable]
[Title("Master", "Visual Effect")]
sealed class VfxMasterNode : AbstractMaterialNode, IMasterNode, IHasSettings, IMayRequirePosition
sealed class VfxMasterNode : AbstractMaterialNode, IMasterNode, IMayRequirePosition
{
const string BaseColorSlotName = "Base Color";
const string MetallicSlotName = "Metallic";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ public virtual bool canSetPrecision

private ConcretePrecision m_ConcretePrecision = ConcretePrecision.Float;

[Inspectable("Precision", ConcretePrecision.Float)]
public ConcretePrecision concretePrecision
{
get => m_ConcretePrecision;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace UnityEditor.ShaderGraph
{
[Title("Input", "Texture", SampleVirtualTextureNode.DefaultNodeTitle)]
class SampleVirtualTextureNode : AbstractMaterialNode, IGeneratesBodyCode, IGeneratesFunction, IMayRequireMeshUV, IMayRequireTime, IMayRequireScreenPosition, IHasSettings
class SampleVirtualTextureNode : AbstractMaterialNode, IGeneratesBodyCode, IGeneratesFunction, IMayRequireMeshUV, IMayRequireTime, IMayRequireScreenPosition
{
public const string DefaultNodeTitle = "Sample Virtual Texture";

Expand Down Expand Up @@ -144,6 +144,8 @@ public bool noFeedback
}
}

public TextureType[] textureTypes => m_TextureTypes;

[SerializeField]
protected TextureType[] m_TextureTypes = { TextureType.Default, TextureType.Default, TextureType.Default, TextureType.Default };

Expand All @@ -164,143 +166,6 @@ public NormalMapSpace normalMapSpace
}
}

/*
The panel behind the cogwheel node settings
*/
class SampleVirtualTextureNodeSettingsView : VisualElement
{
SampleVirtualTextureNode m_Node;
public SampleVirtualTextureNodeSettingsView(SampleVirtualTextureNode node)
{
m_Node = node;

PropertySheet ps = new PropertySheet();

ps.Add(new PropertyRow(new Label("Lod Mode")), (row) =>
{
row.Add(new UIElements.EnumField(m_Node.lodCalculation), (field) =>
{
field.value = m_Node.lodCalculation;
field.RegisterValueChangedCallback(evt =>
{
if (m_Node.lodCalculation == (LodCalculation)evt.newValue)
return;

m_Node.owner.owner.RegisterCompleteObjectUndo("Lod Mode Change");
m_Node.lodCalculation = (LodCalculation)evt.newValue;
});
});
});

ps.Add(new PropertyRow(new Label("Quality")), (row) =>
{
row.Add(new UIElements.EnumField(m_Node.sampleQuality), (field) =>
{
field.value = m_Node.sampleQuality;
field.RegisterValueChangedCallback(evt =>
{
if (m_Node.sampleQuality == (QualityMode)evt.newValue)
return;

m_Node.owner.owner.RegisterCompleteObjectUndo("Quality Change");
m_Node.sampleQuality = (QualityMode)evt.newValue;
});
});
});

ps.Add(new PropertyRow(new Label("No Feedback")), (row) =>
{
row.Add(new UnityEngine.UIElements.Toggle(), (field) =>
{
field.value = m_Node.noFeedback;
field.RegisterValueChangedCallback(evt =>
{
if (m_Node.noFeedback == evt.newValue)
return;

m_Node.owner.owner.RegisterCompleteObjectUndo("Feedback Settings Change");
m_Node.noFeedback = evt.newValue;
});
});
});

var vtProperty = m_Node.GetSlotProperty(VirtualTextureInputId) as VirtualTextureShaderProperty;
if (vtProperty == null)
{
ps.Add(new HelpBoxRow(MessageType.Warning), (row) => row.Add(new Label("Please connect a VirtualTexture property to configure texture sampling type.")));
}
else
{
int numLayers = vtProperty.value.layers.Count;

for (int i = 0; i < numLayers; i++)
{
int currentIndex = i; // to make lambda by-ref capturing happy
ps.Add(new PropertyRow(new Label("Layer " + (i + 1) + " Type")), (row) =>
{
row.Add(new UIElements.EnumField(m_Node.m_TextureTypes[i]), (field) =>
{
field.value = m_Node.m_TextureTypes[i];
field.RegisterValueChangedCallback(evt =>
{
if (m_Node.m_TextureTypes[currentIndex] == (TextureType)evt.newValue)
return;

m_Node.owner.owner.RegisterCompleteObjectUndo("Texture Type Change");
m_Node.m_TextureTypes[currentIndex] = (TextureType)evt.newValue;
m_Node.Dirty(ModificationScope.Graph);
});
});
});
}
}

ps.Add(new PropertyRow(new Label("Normal Space")), (row) =>
{
row.Add(new UIElements.EnumField(m_Node.normalMapSpace), (field) =>
{
field.value = m_Node.normalMapSpace;
field.RegisterValueChangedCallback(evt =>
{
if (m_Node.normalMapSpace == (NormalMapSpace)evt.newValue)
return;

m_Node.owner.owner.RegisterCompleteObjectUndo("Normal Map space Change");
m_Node.normalMapSpace = (NormalMapSpace)evt.newValue;
});
});
});

// display warning if the current master node doesn't support virtual texturing
if (!m_Node.owner.isSubGraph)
{
bool supportedByMasterNode = m_Node.owner.GetNodes<IMasterNode>().FirstOrDefault()?.supportsVirtualTexturing ?? false;
if (!supportedByMasterNode)
ps.Add(new HelpBoxRow(MessageType.Warning), (row) => row.Add(new Label("The current master node does not support Virtual Texturing, this node will do regular 2D sampling.")));
}

// display warning if the current render pipeline doesn't support virtual texturing
IVirtualTexturingEnabledRenderPipeline vtRp = GraphicsSettings.currentRenderPipeline as IVirtualTexturingEnabledRenderPipeline;
if (vtRp == null)
ps.Add(new HelpBoxRow(MessageType.Warning), (row) => row.Add(new Label("The current render pipeline does not support Virtual Texturing, this node will do regular 2D sampling.")));
else if (vtRp.virtualTexturingEnabled == false)
ps.Add(new HelpBoxRow(MessageType.Warning), (row) => row.Add(new Label("The current render pipeline has disabled Virtual Texturing, this node will do regular 2D sampling.")));
else
{
#if !ENABLE_VIRTUALTEXTURES
ps.Add(new HelpBoxRow(MessageType.Warning), (row) => row.Add(new Label("Virtual Texturing is disabled globally (possibly by the render pipeline settings), this node will do regular 2D sampling.")));
#endif
}

Add(ps);
}
}

public VisualElement CreateSettingsElement()
{
return new SampleVirtualTextureNodeSettingsView(this);
}

public SampleVirtualTextureNode() : this(false, false)
{ }

Expand Down
Loading