Skip to content

Commit

Permalink
Fix Several issue in Property Binder (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulDemeulenaere authored and julienf-unity committed Nov 16, 2020
1 parent 4c9bb9e commit 62d8a60
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 13 deletions.
5 changes: 5 additions & 0 deletions com.unity.visualeffectgraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fix for VisualEffect prefab override window [Case 1242693](https://issuetracker.unity3d.com/product/unity/issues/guid/1242693/)
- Fix edited operator being collapsed [Case 1270517](https://issuetracker.unity3d.com/product/unity/issues/guid/1270517/)
- "Create new VisualEffect Graph" creates a graph from the default template [Case 1279999](https://fogbugz.unity3d.com/f/cases/1279999/)
- Property Binder : Incorrect Destroy called from edit mode. [Case 1274790](https://issuetracker.unity3d.com/product/unity/issues/guid/1274790/)
- Property Binder : Unexpected null reference exception while using terrain binder. [Case 1247230](https://issuetracker.unity3d.com/product/unity/issues/guid/1247230/)
- Property Binder : HierarchyRoot null reference exception while using Hierarchy to Attribute Map. [Case 1274788](https://issuetracker.unity3d.com/product/unity/issues/guid/1274788/)
- Property Binder : Properties window isn't always up to date. [Case 1248711](https://issuetracker.unity3d.com/product/unity/issues/guid/1248711/)
- 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/)

## [8.2.0] - 2020-07-08

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ private void OnDisable()

public override void OnInspectorGUI()
{
serializedObject.Update();

EditorGUI.BeginChangeCheck();
EditorGUILayout.Space();
EditorGUILayout.PropertyField(m_ExecuteInEditor);
Expand All @@ -65,8 +67,10 @@ public override void OnInspectorGUI()
EditorGUILayout.Space();
if (EditorGUI.EndChangeCheck())
serializedObject.ApplyModifiedProperties();
if (m_ElementEditor != null)
if (m_ElementEditor != null && m_ElementEditor.target != null && m_ElementEditor.serializedObject.targetObject != null)
{
m_ElementEditor.serializedObject.Update();

EditorGUI.BeginChangeCheck();

var fieldAttribute = BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,67 @@ protected override void SetEventAttribute(object[] parameters)
}
}

private void OnMouseDown()
private void DoOnMouseDown()
{
if (activation == Activation.OnMouseDown) SendEventToVisualEffect();
}

private void OnMouseUp()
private void DoOnMouseUp()
{
if (activation == Activation.OnMouseUp) SendEventToVisualEffect();
}

private void OnMouseDrag()
private void DoOnMouseDrag()
{
if (activation == Activation.OnMouseDrag) SendEventToVisualEffect();
}

private void OnMouseOver()
private void DoOnMouseOver()
{
if (activation == Activation.OnMouseOver) SendEventToVisualEffect();
}

private void OnMouseEnter()
private void DoOnMouseEnter()
{
if (activation == Activation.OnMouseEnter) SendEventToVisualEffect();
}

private void OnMouseExit()
private void DoOnMouseExit()
{
if (activation == Activation.OnMouseExit) SendEventToVisualEffect();
}

#if !PLATFORM_ANDROID && !PLATFORM_IOS
private void OnMouseDown()
{
DoOnMouseDown();
}

private void OnMouseUp()
{
DoOnMouseUp();
}

private void OnMouseDrag()
{
DoOnMouseDrag();
}

private void OnMouseOver()
{
DoOnMouseOver();
}

private void OnMouseEnter()
{
DoOnMouseEnter();
}

private void OnMouseExit()
{
DoOnMouseExit();
}
#endif
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public enum RadiusMode
Interpolate
}

public Transform HierarchyRoot = null;
public Transform HierarchyRoot;
public float DefaultRadius = 0.1f;
public uint MaximumDepth = 3;
public RadiusMode Radius = RadiusMode.Fixed;
Expand Down Expand Up @@ -69,6 +69,9 @@ void UpdateHierarchy()
List<Bone> ChildrenOf(Transform source, uint depth)
{
List<Bone> output = new List<Bone>();
if (source == null)
return output;

foreach (Transform child in source)
{
output.Add(new Bone()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class VFXInputButtonBinder : VFXBinderBase
public float SmoothSpeed = 2.0f;
public bool UseButtonSmooth = true;

#if ENABLE_LEGACY_INPUT_MANAGER
float m_CachedSmoothValue = 0.0f;
#endif

public override bool IsValid(VisualEffect component)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class VFXInputKeyBinder : VFXBinderBase
public float SmoothSpeed = 2.0f;
public bool UseKeySmooth = true;

#if ENABLE_LEGACY_INPUT_MANAGER
float m_CachedSmoothValue = 0.0f;
#endif

public override bool IsValid(VisualEffect component)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class VFXTerrainBinder : VFXBinderBase
public string Property { get { return (string)m_Property; } set { m_Property = value; UpdateSubProperties(); } }

[VFXPropertyBinding("UnityEditor.VFX.TerrainType"), UnityEngine.Serialization.FormerlySerializedAs("TerrainParameter")]
public ExposedProperty m_Property;
public ExposedProperty m_Property = "Terrain";
public Terrain Terrain = null;

private ExposedProperty Terrain_Bounds_center;
Expand Down Expand Up @@ -58,7 +58,7 @@ public override void UpdateBinding(VisualEffect component)

public override string ToString()
{
return string.Format("Sphere : '{0}' -> {1}", m_Property, Terrain == null ? "(null)" : Terrain.name);
return string.Format("Terrain : '{0}' -> {1}", m_Property, Terrain == null ? "(null)" : Terrain.name);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ private void OnEnable()
{
m_VisualEffect = GetComponent<VisualEffect>();
}
static private void SafeDestroy(Object toDelete)
{
if (Application.isPlaying)
Destroy(toDelete);
else
DestroyImmediate(toDelete);
}

private void Reset()
{
Expand Down Expand Up @@ -92,7 +99,8 @@ void LateUpdate()
public void ClearPropertyBinders()
{
var allBinders = GetComponents<VFXBinderBase>();
foreach (var binder in allBinders) Destroy(binder);
foreach (var binder in allBinders)
SafeDestroy(binder);
}

/// <summary>
Expand All @@ -110,7 +118,8 @@ public void ClearParameterBinders()
/// <param name="binder">The VFXBinderBase to remove</param>
public void RemovePropertyBinder(VFXBinderBase binder)
{
if (binder.gameObject == this.gameObject) Destroy(binder);
if (binder.gameObject == this.gameObject)
SafeDestroy(binder);
}

/// <summary>
Expand All @@ -131,7 +140,8 @@ public void RemoveParameterBinder(VFXBinderBase binder)
{
var allBinders = GetComponents<VFXBinderBase>();
foreach (var binder in allBinders)
if (binder is T) Destroy(binder);
if (binder is T)
SafeDestroy(binder);
}

/// <summary>
Expand Down

0 comments on commit 62d8a60

Please sign in to comment.