Skip to content

Commit e92e849

Browse files
committed
Added check for attributes
1 parent 0b0f83e commit e92e849

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using UnityEditor;
2+
using UnityEngine;
3+
using UnityEngine.UIElements;
4+
5+
namespace VRLabs.ModularShaderSystem.UI
6+
{
7+
public class PropertyAttributeAttribute : PropertyAttribute
8+
{
9+
}
10+
/// <summary>
11+
/// Inspector drawer for <see cref="Variable"/>.
12+
/// </summary>
13+
[CustomPropertyDrawer(typeof(PropertyAttributeAttribute))]
14+
public class PropertyAttributeDrawer : PropertyDrawer
15+
{
16+
public override VisualElement CreatePropertyGUI(SerializedProperty property)
17+
{
18+
var root = new VisualElement();
19+
20+
var value = new TextField();
21+
value.SetValueWithoutNotify(property.stringValue);
22+
root.Add(value);
23+
24+
/*value.RegisterValueChangedCallback(evt =>
25+
{
26+
property.stringValue = evt.newValue;
27+
property.serializedObject.ApplyModifiedProperties();
28+
});*/
29+
value.RegisterCallback<FocusOutEvent>(evt =>
30+
{
31+
string v = value.value;
32+
if (v[v.Length - 1] == ']')
33+
{
34+
v = v.Remove(v.Length - 1, 1);
35+
}
36+
if (v[0] == '[')
37+
{
38+
v = v.Remove(0, 1);
39+
}
40+
property.stringValue = v;
41+
value.SetValueWithoutNotify(property.stringValue);
42+
property.serializedObject.ApplyModifiedProperties();
43+
});
44+
45+
/*customTypeField.style.display = ((VariableType)typeField.value) == VariableType.Custom ? DisplayStyle.Flex : DisplayStyle.None;
46+
47+
typeField.RegisterValueChangedCallback(e =>
48+
{
49+
customTypeField.style.display = ((VariableType)e.newValue) == VariableType.Custom ? DisplayStyle.Flex : DisplayStyle.None;
50+
});*/
51+
52+
return root;
53+
}
54+
}
55+
}

Editor/Editors/Drawers/PropertyAttributeDrawer.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/Scriptables/Property.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using UnityEngine;
4+
using VRLabs.ModularShaderSystem.UI;
45

56
namespace VRLabs.ModularShaderSystem
67
{
@@ -55,6 +56,7 @@ public class Property : IEquatable<Property>
5556
/// <summary>
5657
/// List of attributes for the shader property.
5758
/// </summary>
59+
[PropertyAttribute]
5860
public List<string> Attributes;
5961

6062
/// <summary>

0 commit comments

Comments
 (0)