-
Notifications
You must be signed in to change notification settings - Fork 860
[9.x.x] Internal Inspector #173
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
Changes from 1 commit
9b394e6
b1bc7a6
a1da944
e39f40f
e8458a8
9bf669f
6940b26
a817799
bb72709
847d7ab
c5e482d
2195af3
73249d3
46551c4
6bcec64
e0080cf
1e808db
85c8ae0
7d37d2d
29a6520
490881f
a49ac71
ad9543f
a30ad23
4b86947
696b8b1
c53758a
d5de054
618261d
56ebea6
718ed66
7a735e1
3af7441
42d25b7
79cb5ba
f8f9715
0f421d6
9f52081
8213926
1f9c796
3d29416
3a63294
16075a4
6aa0ec1
a7616a3
179df8a
3c3c20f
b94a5d9
f865524
a11ba53
039a7a0
69e928b
933f6b3
acde56b
c3df6fe
60649b0
d3c67d8
63b8f3a
49d3b75
471a389
f11a7be
b105f46
89afe4e
41ad40e
587eec2
4fc2340
500c175
eb80a60
a3f7cdf
500a509
ec3ecbf
e6406ed
31b8c76
89389dc
b7b9227
09c4ef5
635988a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| using System; | ||
|
|
||
| namespace UnityEditor.ShaderGraph.Drawing | ||
| { | ||
| [AttributeUsage(AttributeTargets.Class)] | ||
| public class SGPropertyDrawerAttribute : Attribute | ||
| { | ||
| public Type propertyType { get; private set; } | ||
|
|
||
| public SGPropertyDrawerAttribute(Type propertyType) | ||
| { | ||
| this.propertyType = propertyType; | ||
| } | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| using System; | ||
| using System.Reflection; | ||
| using UnityEditor.ShaderGraph.Drawing; | ||
| using UnityEngine.UIElements; | ||
|
|
||
| namespace Data.Interfaces | ||
| { | ||
| // Interface that should be implemented by any property drawer for the inspector view | ||
| public interface IPropertyDrawer | ||
| { | ||
| Action inspectorUpdateDelegate { get; set; } | ||
|
|
||
| VisualElement DrawProperty(PropertyInfo propertyInfo, object actualObject, InspectableAttribute attribute); | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| using System; | ||
| using System.Reflection; | ||
| using Data.Interfaces; | ||
| using UnityEditor.Graphing.Util; | ||
| using UnityEditor.ShaderGraph.Drawing; | ||
| using UnityEngine; | ||
| using UnityEngine.UIElements; | ||
|
|
||
| namespace Drawing.Inspector.PropertyDrawers | ||
| { | ||
| [SGPropertyDrawer(typeof(bool))] | ||
| class BoolPropertyDrawer : IPropertyDrawer | ||
| { | ||
| internal delegate void ValueChangedCallback(bool newValue); | ||
|
|
||
| internal VisualElement CreateGUI( | ||
| ValueChangedCallback valueChangedCallback, | ||
| bool fieldToDraw, | ||
| string labelName, | ||
| out VisualElement propertyToggle, | ||
| int indentLevel = 0) | ||
| { | ||
| var row = new PropertyRow(PropertyDrawerUtils.CreateLabel(labelName, indentLevel)); | ||
| // Create and assign toggle as out variable here so that callers can also do additional work with enabling/disabling if needed | ||
| propertyToggle = new Toggle(); | ||
| row.Add((Toggle)propertyToggle, (toggle) => | ||
| { | ||
| toggle.value = fieldToDraw; | ||
| }); | ||
|
|
||
| if (valueChangedCallback != null) | ||
| { | ||
| var toggle = (Toggle) propertyToggle; | ||
| toggle.OnToggleChanged(evt => valueChangedCallback(evt.newValue)); | ||
| } | ||
|
|
||
| row.styleSheets.Add(Resources.Load<StyleSheet>("Styles/PropertyRow")); | ||
| return row; | ||
| } | ||
|
|
||
| public Action inspectorUpdateDelegate { get; set; } | ||
|
|
||
| public VisualElement DrawProperty( | ||
| PropertyInfo propertyInfo, | ||
| object actualObject, | ||
| InspectableAttribute attribute) | ||
| { | ||
| return this.CreateGUI( | ||
| // Use the setter from the provided property as the callback | ||
| newBoolValue => propertyInfo.GetSetMethod(true).Invoke(actualObject, new object[] {newBoolValue}), | ||
| (bool) propertyInfo.GetValue(actualObject), | ||
| attribute.labelName, | ||
| out var propertyVisualElement); | ||
| } | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.