Skip to content

Commit 62d8a60

Browse files
PaulDemeulenaerejulienf-unity
authored andcommitted
Fix Several issue in Property Binder (#106)
1 parent 4c9bb9e commit 62d8a60

File tree

8 files changed

+71
-13
lines changed

8 files changed

+71
-13
lines changed

com.unity.visualeffectgraph/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
4040
- Fix for VisualEffect prefab override window [Case 1242693](https://issuetracker.unity3d.com/product/unity/issues/guid/1242693/)
4141
- Fix edited operator being collapsed [Case 1270517](https://issuetracker.unity3d.com/product/unity/issues/guid/1270517/)
4242
- "Create new VisualEffect Graph" creates a graph from the default template [Case 1279999](https://fogbugz.unity3d.com/f/cases/1279999/)
43+
- Property Binder : Incorrect Destroy called from edit mode. [Case 1274790](https://issuetracker.unity3d.com/product/unity/issues/guid/1274790/)
44+
- Property Binder : Unexpected null reference exception while using terrain binder. [Case 1247230](https://issuetracker.unity3d.com/product/unity/issues/guid/1247230/)
45+
- Property Binder : HierarchyRoot null reference exception while using Hierarchy to Attribute Map. [Case 1274788](https://issuetracker.unity3d.com/product/unity/issues/guid/1274788/)
46+
- Property Binder : Properties window isn't always up to date. [Case 1248711](https://issuetracker.unity3d.com/product/unity/issues/guid/1248711/)
47+
- Property Binder : Avoid Warning while building on Mobile "Presence of such handlers might impact performance on handheld devices." when building for Android" [Case 1279471](https://issuetracker.unity3d.com/product/unity/issues/guid/1248711/)
4348

4449
## [8.2.0] - 2020-07-08
4550

com.unity.visualeffectgraph/Editor/Utilities/PropertyBinding/VFXPropertyBinderEditor.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ private void OnDisable()
5757

5858
public override void OnInspectorGUI()
5959
{
60+
serializedObject.Update();
61+
6062
EditorGUI.BeginChangeCheck();
6163
EditorGUILayout.Space();
6264
EditorGUILayout.PropertyField(m_ExecuteInEditor);
@@ -65,8 +67,10 @@ public override void OnInspectorGUI()
6567
EditorGUILayout.Space();
6668
if (EditorGUI.EndChangeCheck())
6769
serializedObject.ApplyModifiedProperties();
68-
if (m_ElementEditor != null)
70+
if (m_ElementEditor != null && m_ElementEditor.target != null && m_ElementEditor.serializedObject.targetObject != null)
6971
{
72+
m_ElementEditor.serializedObject.Update();
73+
7074
EditorGUI.BeginChangeCheck();
7175

7276
var fieldAttribute = BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic;

com.unity.visualeffectgraph/Runtime/Utilities/EventBinding/Implementation/VFXMouseEventBinder.cs

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,35 +40,67 @@ protected override void SetEventAttribute(object[] parameters)
4040
}
4141
}
4242

43-
private void OnMouseDown()
43+
private void DoOnMouseDown()
4444
{
4545
if (activation == Activation.OnMouseDown) SendEventToVisualEffect();
4646
}
4747

48-
private void OnMouseUp()
48+
private void DoOnMouseUp()
4949
{
5050
if (activation == Activation.OnMouseUp) SendEventToVisualEffect();
5151
}
5252

53-
private void OnMouseDrag()
53+
private void DoOnMouseDrag()
5454
{
5555
if (activation == Activation.OnMouseDrag) SendEventToVisualEffect();
5656
}
5757

58-
private void OnMouseOver()
58+
private void DoOnMouseOver()
5959
{
6060
if (activation == Activation.OnMouseOver) SendEventToVisualEffect();
6161
}
6262

63-
private void OnMouseEnter()
63+
private void DoOnMouseEnter()
6464
{
6565
if (activation == Activation.OnMouseEnter) SendEventToVisualEffect();
6666
}
6767

68-
private void OnMouseExit()
68+
private void DoOnMouseExit()
6969
{
7070
if (activation == Activation.OnMouseExit) SendEventToVisualEffect();
7171
}
72+
73+
#if !PLATFORM_ANDROID && !PLATFORM_IOS
74+
private void OnMouseDown()
75+
{
76+
DoOnMouseDown();
77+
}
78+
79+
private void OnMouseUp()
80+
{
81+
DoOnMouseUp();
82+
}
83+
84+
private void OnMouseDrag()
85+
{
86+
DoOnMouseDrag();
87+
}
88+
89+
private void OnMouseOver()
90+
{
91+
DoOnMouseOver();
92+
}
93+
94+
private void OnMouseEnter()
95+
{
96+
DoOnMouseEnter();
97+
}
98+
99+
private void OnMouseExit()
100+
{
101+
DoOnMouseExit();
102+
}
103+
#endif
72104
}
73105
}
74106
#endif

com.unity.visualeffectgraph/Runtime/Utilities/PropertyBinding/Implementation/VFXHierarchyAttributeMapBinder.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public enum RadiusMode
2525
Interpolate
2626
}
2727

28-
public Transform HierarchyRoot = null;
28+
public Transform HierarchyRoot;
2929
public float DefaultRadius = 0.1f;
3030
public uint MaximumDepth = 3;
3131
public RadiusMode Radius = RadiusMode.Fixed;
@@ -69,6 +69,9 @@ void UpdateHierarchy()
6969
List<Bone> ChildrenOf(Transform source, uint depth)
7070
{
7171
List<Bone> output = new List<Bone>();
72+
if (source == null)
73+
return output;
74+
7275
foreach (Transform child in source)
7376
{
7477
output.Add(new Bone()

com.unity.visualeffectgraph/Runtime/Utilities/PropertyBinding/Implementation/VFXInputButtonBinder.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ class VFXInputButtonBinder : VFXBinderBase
2020
public float SmoothSpeed = 2.0f;
2121
public bool UseButtonSmooth = true;
2222

23+
#if ENABLE_LEGACY_INPUT_MANAGER
2324
float m_CachedSmoothValue = 0.0f;
25+
#endif
2426

2527
public override bool IsValid(VisualEffect component)
2628
{

com.unity.visualeffectgraph/Runtime/Utilities/PropertyBinding/Implementation/VFXInputKeyBinder.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ class VFXInputKeyBinder : VFXBinderBase
2020
public float SmoothSpeed = 2.0f;
2121
public bool UseKeySmooth = true;
2222

23+
#if ENABLE_LEGACY_INPUT_MANAGER
2324
float m_CachedSmoothValue = 0.0f;
25+
#endif
2426

2527
public override bool IsValid(VisualEffect component)
2628
{

com.unity.visualeffectgraph/Runtime/Utilities/PropertyBinding/Implementation/VFXTerrainBinder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class VFXTerrainBinder : VFXBinderBase
1010
public string Property { get { return (string)m_Property; } set { m_Property = value; UpdateSubProperties(); } }
1111

1212
[VFXPropertyBinding("UnityEditor.VFX.TerrainType"), UnityEngine.Serialization.FormerlySerializedAs("TerrainParameter")]
13-
public ExposedProperty m_Property;
13+
public ExposedProperty m_Property = "Terrain";
1414
public Terrain Terrain = null;
1515

1616
private ExposedProperty Terrain_Bounds_center;
@@ -58,7 +58,7 @@ public override void UpdateBinding(VisualEffect component)
5858

5959
public override string ToString()
6060
{
61-
return string.Format("Sphere : '{0}' -> {1}", m_Property, Terrain == null ? "(null)" : Terrain.name);
61+
return string.Format("Terrain : '{0}' -> {1}", m_Property, Terrain == null ? "(null)" : Terrain.name);
6262
}
6363
}
6464
}

com.unity.visualeffectgraph/Runtime/Utilities/PropertyBinding/VFXPropertyBinder.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ private void OnEnable()
3535
{
3636
m_VisualEffect = GetComponent<VisualEffect>();
3737
}
38+
static private void SafeDestroy(Object toDelete)
39+
{
40+
if (Application.isPlaying)
41+
Destroy(toDelete);
42+
else
43+
DestroyImmediate(toDelete);
44+
}
3845

3946
private void Reset()
4047
{
@@ -92,7 +99,8 @@ public T AddParameterBinder<T>() where T : VFXBinderBase
9299
public void ClearPropertyBinders()
93100
{
94101
var allBinders = GetComponents<VFXBinderBase>();
95-
foreach (var binder in allBinders) Destroy(binder);
102+
foreach (var binder in allBinders)
103+
SafeDestroy(binder);
96104
}
97105

98106
/// <summary>
@@ -110,7 +118,8 @@ public void ClearParameterBinders()
110118
/// <param name="binder">The VFXBinderBase to remove</param>
111119
public void RemovePropertyBinder(VFXBinderBase binder)
112120
{
113-
if (binder.gameObject == this.gameObject) Destroy(binder);
121+
if (binder.gameObject == this.gameObject)
122+
SafeDestroy(binder);
114123
}
115124

116125
/// <summary>
@@ -131,7 +140,8 @@ public void RemovePropertyBinders<T>() where T : VFXBinderBase
131140
{
132141
var allBinders = GetComponents<VFXBinderBase>();
133142
foreach (var binder in allBinders)
134-
if (binder is T) Destroy(binder);
143+
if (binder is T)
144+
SafeDestroy(binder);
135145
}
136146

137147
/// <summary>

0 commit comments

Comments
 (0)