Browse Source

Added null checks to flowchart window reflection code in case of breaking updates

Added null checks to getting the “docked” property of the flowchart
window in case this property gets changed or removed in the future. The
default offset values should still be acceptable.
master
Zach Vinless 8 years ago
parent
commit
b1004a79c2
  1. 24
      Assets/Fungus/Scripts/Editor/FlowchartWindow.cs

24
Assets/Fungus/Scripts/Editor/FlowchartWindow.cs

@ -95,16 +95,24 @@ namespace Fungus.EditorUtils
// The docked value doesn't always report correctly without the delayCall // The docked value doesn't always report correctly without the delayCall
EditorApplication.delayCall += () => { EditorApplication.delayCall += () => {
var flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance; var flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
var isDockedMethod = typeof(EditorWindow).GetProperty("docked", flags).GetGetMethod(true); var dockedProperty = typeof(EditorWindow).GetProperty("docked", flags);
if ((bool) isDockedMethod.Invoke(this, null))
{ if (dockedProperty != null)
EditorZoomArea.Offset = new Vector2(2.0f, 19.0f);
}
else
{ {
EditorZoomArea.Offset = new Vector2(0.0f, 22.0f); var isDockedMethod = dockedProperty.GetGetMethod(true);
if (isDockedMethod != null)
{
if ((bool) isDockedMethod.Invoke(this, null))
{
EditorZoomArea.Offset = new Vector2(2.0f, 19.0f);
}
else
{
EditorZoomArea.Offset = new Vector2(0.0f, 22.0f);
}
}
} }
}; };
} }
public static Flowchart GetFlowchart() public static Flowchart GetFlowchart()

Loading…
Cancel
Save